Questions tagged [map-operator]
Use this tag for questions about creating your own operator within vim.
45 questions
2 votes
5 answers
286 views
How to insert a recorded macro (register content, with control character) in a vim function created for a plugin?
I did a macro, that works, and I want to save it for future use. I am afraid to leave the macro in the registry because it might be overwritten, then I want to save it in a function (or a plugin). I ...
0 votes
2 answers
69 views
Usage of opfunc and g@: is there a simple way to save/restore option?
I read the example in :h map-operator which does the job but it is very convoluted. I am wondering if there is a simpler way to save/restore options before/after having set 'opfunc' and run g@. My ...
2 votes
3 answers
529 views
Correctly escaping <CR>: how can I map a command to send the literal string "<CR>" to a vim function?
I'm currently trying to create a mapping that sends a command and a newline to an open terminal using nnoremap and term_sendkeys(). term_sendkeys() interprets the \<CR> string as a newline, so ...
6 votes
1 answer
915 views
vi (an old AIX vi, not vim): map: I can search, move, yank, or dd, but cannot paste
On regular AIX vi (not vim, just plain old vi): I tried to do the following map, but it fails on the "P" or "p" part with the message Cannot use the put command while inside a ...
1 vote
2 answers
122 views
Unmap error in filetype autocommand
I use a plugin for todo.txt file (https://gitlab.com/dbeniamine/todo.txt-vim). Because I mapped some d[other_letters] in my .vimrc and there's a \d mapped in the plugin, to avoid delays when I type \d ...
2 votes
1 answer
294 views
Get motion used within operatorfunction?
How can I make a custom operator function that can programmatically reuse the motion that the user called it with? E.g. I want to map the operator m so that miw goes to the start of the file and then ...
2 votes
1 answer
96 views
Different replace patterns depending on visual/visual line mode
I've written some customizations in my .vimrc that I would like to further improve and refine. In particular, for some key combinations, I'm doing text substitutions, like this: vmap <C-S-w> :s/\...
0 votes
1 answer
69 views
Opfunc inserts text before cursor position sometimes
function! s:Surround(motion = "") abort let [_, l:start_row, l:start_col, _] = getpos("'[") let [_, l:end_row, l:end_col, _] = getpos("']") let l:before = &...
0 votes
1 answer
272 views
How to pass arguments to `:map gx <Plug>(SomeFunction)`?
Context I'm evaluating https://github.com/tyru/open-browser.vim which looks really promising. I figured out how to set the default search engine and add a mapping " vim-openbrowser let g:...
0 votes
1 answer
91 views
Meta-Model: Shrinking In Correct Direction
This questions sounds ridicolous, but is there any (mental?!) aid for my struggle when resizing windows? Since the earliest days of my vi/m usage, I have struggle shrinking windows in the correct ...
2 votes
1 answer
215 views
What is the purpose to use "==#" with empty string?
The following is from vim-sensible plugin: set incsearch " Use <C-L> to clear the highlighting of :set hlsearch. if maparg('<C-L>', 'n') ==# '' nnoremap <silent> <C-L> :...
0 votes
2 answers
341 views
using EasyAlign in a function
I frequently use EasyAlign in my tex files to align tables around the $ delimiter such that this header1 & header2 & header3 \\ data1 & data2 & data3 \\ becomes this header1 & ...
1 vote
1 answer
178 views
Can I allow additional arguments in an operatorfunc?
To call a custom operator with a mapping, one can do nnoremap <Plug>(Foo) :set opfunc=Baa<CR>g@ so that <Plug>(Foo) expects a motion, after which the function Baa is called. Here, ...
1 vote
1 answer
186 views
Auto pairing using strings instead of characters
I'm already aware of existing solution to automatically "surround" sentences/word/etc (eg: auto-surround, vim-surround, etc) but those (as far as i know) don't support using normal strings ...
0 votes
1 answer
93 views
How to map <Plug>MarkdownPreviewToggle
I am trying to map MarkdownPreviewToggle to an key like "mk". My vimrc is like it: nnoremap mk <Plug>MarkdownPreviewToggle But it doesnt work, what should i do? (the other key isnt ...