5

_ is a linewise motion operator (:h linewise), its primary purpose is to move your cursor to <count> - 1 lines below your current position. For example: 5_ will move your cursor 4 lines down The motion to the beginning of the line is just a side effect of that move. So when you type d_, the delete operation is applied from the current line to 0 lines ...


4

Interesting question! 👍 Reading your attempts of code made me think of the order in which the operations are actually executed, which is: The omap motion or text object is executed and selected. The operator command (y, d, g~, etc.) is executed on that block of text. It seems to me that some of your assumptions have the model backwards and assume that ...


3

That is indeed a novel and potentially time-saving feature! The way to do this in plain Vim would be using :substitute for a range; the pattern can be easily set via * when the cursor is on top of it: *vip:s//hi/g<CR> A mapping for the :s///g part that puts the cursor right into the replacement part can save many keystrokes here. In order to ...


2

There's no way to change this behavior for all operators (short of mapping them all.) But you can make your <F4> keep the cursor position (and window view) by saving and restoring it before and after it's used. Note that since <F4> ends in an operator-pending g@ command, saving and restoring need to happen in different contexts, you should save ...


2

You can come up with something relatively simple, following and tinkering what vim has described in :h :map-operator: As an example I came up with in about 15 minutes of experimenting: nmap <silent> gi :set opfunc=InsertToTextObject<CR>g@ vmap <silent> gi :<C-U>call InsertToTextObject(visualmode(), 1)<CR> nmap <silent> ...


1

Visually select motion text, execute existing operator: function! OperatorFunc(type, ...) " change op to desired operator call ExecuteOperator(a:type, a:0 > 0, 'op') " do other stuff endfunction function! ExecuteOperator(type, visual, operator) if a:visual exe 'norm gv'.a:operator els exe printf('`[%s`]%s', a:type ==# 'line' ? 'V' : ...


Only top voted, non community-wiki answers of a minimum length are eligible