Targeted linewise motions and edits
- Jump to a target on the same line with a single keystroke, no matter the distance
- Quickly fix common typos using insertion, swap, replace, and cut
The plugin API is exposed via "named key sequences"; see this write-up on why this is a good idea.
We want to jump to the last "o" in front of the cursor, but there are several other "o"'s in the way.
map <leader><leader>f <Plug>(snipe-f)
We want to jump to the end of "to".
map <leader><leader>ge <Plug>(snipe-ge)
Fix "smlal" by swapping a previous instance of "l".
nmap <leader><leader>] <Plug>(snipe-f-xp) nmap <leader><leader>[ <Plug>(snipe-F-xp)
Fix "smoall" by cutting an instance of "o".
nmap <leader><leader>x <Plug>(snipe-f-x) nmap <leader><leader>X <Plug>(snipe-F-x)
Fix "smbll" by replacing an instance of "b".
nmap <leader><leader>r <Plug>(snipe-f-r) nmap <leader><leader>R <Plug>(snipe-F-r)
Fix "missig" by appending an "n" after the second "i".
nmap <leader><leader>a <Plug>(snipe-f-a) nmap <leader><leader>A <Plug>(snipe-F-a)
By default, the jump tokens are row-ordered starting with the home row:
asdfghjklqwertyuiopzxcvbnm. You can provide your own sequence by setting a global variable
g:snipe_jump_tokens. For Dvorak users, e.g.
let g:snipe_jump_tokens = 'aoeuidhtns'
You can also provide your own highlighting via
let g:snipe_highlight_gui_color = '#fabd2f' let g:snipe_highlight_cterm256_color = '200' let g:snipe_highlight_cterm_color = 7'
These are used to build the highlighting group in highlight.vim used when highlighting a jump sequence.
For the full documentation, do
Why did you constrain to
set relativenumber, scanning the buffer is overkill and unnecessarily slow.
Should I always use this over the built-in motions?
No, in some cases (i.e. a single hop to an adjacent word, or when the target is obviously unique on the path to the cursor), it's probably faster to use the built-in motions.
Pick the right tool for the right job; I use vim-snipe constantly, but I don't remap the built-in motions.
Pull requests are welcome; no special process is required.