Skip to content

Latest commit

 

History

History
124 lines (75 loc) · 3.45 KB

README.md

File metadata and controls

124 lines (75 loc) · 3.45 KB

vim-snipe

Linewise motions and edits

gif

Features

  1. Jump to a character on the same line with a single keystroke, no matter the distance
  2. Fix common typos via insertion, swap, replace, and cut

Read this for background and motivation.

The plugin API is exposed via "named key sequences"; see this write-up on why this is a good idea.

Examples

Character motion

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)

f

Word motion

We want to jump to the end of "to".

map <leader><leader>ge <Plug>(snipe-ge)

ge

Swap

Fix "smlal" by swapping a previous instance of "l".

nmap <leader><leader>] <Plug>(snipe-f-xp)
nmap <leader><leader>[ <Plug>(snipe-F-xp)

xp

Cut

Fix "smoall" by cutting an instance of "o".

nmap <leader><leader>x <Plug>(snipe-f-x)
nmap <leader><leader>X <Plug>(snipe-F-x)

x

Replace

Fix "smbll" by replacing an instance of "b".

nmap <leader><leader>r <Plug>(snipe-f-r)
nmap <leader><leader>R <Plug>(snipe-F-r)

r

Append

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)

a

Options

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.

Docs

For the full documentation, do :h snipe.txt.

FAQ

Why did you constrain to line('.')?

Given 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.

Inspiration

Contributing

Pull requests are welcome; no special process is required.