New answers tagged

2

It's not possible to achieve this with regular mappings of K and KK. If the K mapping fires then Vim is necessarily no longer waiting to see if KK is typed, and there are no configuration options that can change this behaviour. There are ways to workaround this, however. filbranden suggested one possible method in the comments which D. Ben Knoble has ...


1

I think something like this would do: let s:pressed = 0 function KFunc() abort let s:pressed += 1 if s:pressed == 1 " do one else if s:pressed == 2 " do two let s:pressed = 0 endif endfunction augroup ResetPressed au! au CursorMoved,CursorMovedI,CursorHold,CursorHoldI * let s:pressed = 0 augroup END nnoremap K :call KFunc()<CR&...


2

It seems you've already found a working solution, but I wanted to address the issues with your attempted approaches. But when I press /, instead of running the function and then starting the search prompt, I get this text inserted to my buffer: rm! / You're getting this result because you're using <BAR> in your mapping after you already left ...


1

Figured out the the <silent> was hiding the search prompt, and also the mapping can be done just like this: nnoremap / :call <SID>FooFunction()<CR>/


4

Change you mapping to nmap instead of nnoremap. nnoremap uses "default" mappings on the right mapped side (it doesn't allow nested mappings, like gcc). Thus nmap yc yygccpi


2

I assume "doesn't hold the cursor" applies to the corner case when the cursor is at the end of the line and virtualedit is empty (then <esc> will move cursor one position backward, to the last existing character). That's often an issue for insert-mode mappings. There's :h i_ctrl-\_ctrl-o which executes one normal mode command without touching the ...


2

I had another binding that <leader>h was a prefix and I had forgotten about; it was <leader>html. Removing it solved the problem.


2

If your {} is on first column: ]] goto next { in first column, it's the open { of next function. ][ goto next } in first column, it's the close } of current function. [[ goto previous { in first column, it's the open { of current function. [] goto previous } in first column, it's the close } of previous function. It doesn't care how many nested {} there ...


10

Are you looking for :h %? % Find the next item in this line after or under the cursor and jump to its match. |inclusive| motion. Items can be: ([{}]) parenthesis or (curly/square) brackets (this can be changed with the 'matchpairs' option) Pressing % in normal mode ...


1

I'm just going by the help doc in github but it appears that 'NERDCreateDefaultMappings' does exactly what you want for the first part, ie. toggle on/off all mappings (bindings)... If set to 0, none of the default mappings will be created. Then you can manually bind to your heart's content. The help for NERDCommenterMappings has a bit of advice for that: ...


Top 50 recent answers are included