Questions tagged [map-operator]
Use this tag for questions about creating your own operator within vim.
22
questions
3
votes
1answer
28 views
Open command-line-mode from VimScript function
How to reproduce this mapping:
nnoremap <Leader>a :DoSomething <C-r>=do_something_arguments()<CR>
..in a function?
The desired effect is to open command-line mode with some text ...
2
votes
1answer
43 views
Map <C-J> to <Space> in all possible modes
My space bar no longer works unless I lean my weight on it. The chances of getting the laptop replaced in a timely manner is close no nil.
I mostly use vim or vi, even from the bash command line. ...
0
votes
0answers
15 views
Spell check operator
Is there a way to run the spell checking for a single text object instead of the entire file?
I would like to do something like:
gsip (go spell in paragraph)
I've found a gammar check operator:
...
0
votes
2answers
24 views
how can i remap <C-w>{number}h to <C-w>{number}j
I am trying to remap my hjkl keys to jklö. this is not a problem in most simple cases, but with commands like <C-w>h where you can specify an amount in the form of <C-w>{count}h or {count}&...
4
votes
1answer
71 views
How to pass v:register to custom operator when working on custom text object?
I have a simple custom operator, it echoes v:register, it's mapped to ,f. After reading this, i creat it like this :
function! s:foo(type,...)
echo v:register
endfunction
function! s:setupOpfunc(...
2
votes
1answer
39 views
Alternate vim mapping
I have a file that looks something like this
\usepackage{tex/Forkurs-1p-2p-laererutdanning-2018-V}
\usepackage{../Sty/hyper}
\begin{document}
\input{tex/Forkurs-1p-2p-laererutdanning-2018-V-...
2
votes
0answers
30 views
Do operator ranges/movements/textobjects always overwrite the last visual selection? workaround?
In vim, when I operate on a textobject from a plugin, say the 'inner indent' typed ii from kana/vim-textobj-indent, my last visual selection ('>, '<) is reset to where the operator worked on. ...
0
votes
1answer
36 views
Mappings with counts at the end without using loops?
Suppose you are trying to create a set of mappings such that pressing <C-t> followed by a number # would alternate to the respective tab at index #. I know that using a loop, I can do:
" Map ...
2
votes
1answer
133 views
Numpad characters don't work in keybindings mappings (but work in general)
For my terminal Vim 8.0, I have downloaded this plugin that makes changing font size on the fly easy:
https://github.com/drmikehenry/vim-fontsize
Following the instructions, here is how I decided to ...
2
votes
1answer
62 views
Modify `iskeyword` for keyword-local completion only
Context
Some time ago, I added the following line to ~/.vim/after/ftplugin/sh.vim to make working with parameter expansions easier:
setlocal iskeyword+=$
This is nice to be able to e.g. ysiw" via ...
3
votes
2answers
112 views
overwrite motion-wiseness of operator pending mode
Background
In :h motion.txt, it says:
FORCING A MOTION TO BE LINEWISE, CHARACTERWISE OR BLOCKWISE
When a motion is not of the type you would like to use, you can force another
type by using "v", "V"...
2
votes
1answer
97 views
Operator pending mode remaps not working
I'm trying to build a vimscript can be used with the Dvorak Simplified Layout. I.e., given that the keys on the keyboard plugged into the computer are laid out in the Dovark Simplified Layout (and the ...
2
votes
1answer
55 views
change inner backslashed quotes
I know the ci" motion and others :changes, but I need something like a ci\" in order to change inner a backslashed quotes. Assuming * as the cursor position:
a = "message says: \"fo*o bar\""
I would ...
0
votes
1answer
95 views
how to accept count for visual block ctrl+a remap?
I have created a vmap but I can't figure out how to apply a count to it.
In this case, the mapping is on <C-a> and 4<C-a> is an example of a command with a count failing to be applied. We ...
6
votes
1answer
413 views
How to allow count *before* my custom operator?
I'd like to define my own operator. Vim's builtin help has a nice little tutorial on it, where they show you can create your own operator with opfunc and g@:
nmap <silent> <F4> :set ...
1
vote
1answer
140 views
How to cancel a custom operator-pending command
I want to make a custom search, accessible with operator-pending commands;
I use onoremap to make it work in this mode.
It's working well, and I can use my command (let's say it's mapped to zz) with ...
1
vote
1answer
48 views
Problem mapping operator
I'm trying to write a mapping that will copy the text and automatically unwrap it at the same time. Here's what I got:
function! CopyUnwrapped(type, ...)
if a:0
normal! gv"ay
else
...
1
vote
1answer
71 views
onoremap: defining a bounded region
I want to craft a custom operator-pending motion if for functions in R language that look like this:
doSomething <- function(arg1, arg2, ...) {
doStuff(...)
}
The idea is to be able to press ...
2
votes
1answer
90 views
Is there a way to make the `r` operator accept a motion?
What I would like to do is issue a raiw where the current word would be replaced by an aaaaa word.
example:
this is a w[o]rd <--- cursor on []
raiw <--- command
this is a aaaa &...
3
votes
1answer
138 views
Abort an operating pending mapping
When creating an operator pending mapping in vim, it is possible make the mapping work on an arbitrary (consecutive) piece of text.
I am looking for a way to abort the operation. For the case of ...
2
votes
0answers
74 views
Avoid ending up in mode from onoremap
When I'm on an empty line and press cfa, nothing happens, whereas on a line with an a, it will go into insert mode.
E.g. I have this:
onoremap <silent> a :normal! Favfz
Whether I am on an ...
8
votes
1answer
63 views
Define text object that depends on the current operator
I'm curious if it is possible to make a text object aware of its operator. In particular, I am writing a text object for LaTeX environments, where I want different behaviour depending on the operator. ...