Giter Club home page Giter Club logo

vim-snipe's Introduction

vim-snipe

Targeted linewise motions and edits

gif

  1. Jump to a target on the same line with a single keystroke, no matter the distance
  2. Quickly fix common typos using 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.

vim-snipe's People

Contributors

hauleth avatar skt041959 avatar yangmillstheory avatar ychin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.