Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The missing motion for Vim 👟

License

NotificationsYou must be signed in to change notification settings

justinmk/vim-sneak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jump to any location specified by two characters.

Sneak is a powerful, reliable, yet minimalmotion plugin for Vim. It works withmultiplelines,operators (including repeat. andsurround), motion-repeat(; and,),keymaps,visual mode,multibyte text, andmacros.

Trylabel-mode for a minimalist alternative toEasyMotion:

letg:sneak#label=1

Usage

Sneak is invoked withs followed by exactly two characters:

s{char}{char}
  • Typesab tomove the cursor immediately to the next instance of the text "ab".
    • Additional matches, if any, are highlighted until the cursor is moved.
  • Type; to go to the next match (ors again, ifs_next is enabled; see:help sneak).
  • Type3; to skip to the third match from the current position.
  • Typectrl-o or`` to go back to the starting point.
    • This is a built-in Vim motion; Sneak adds to Vim'sjumplistonly ons invocation—not repeats—so you canabandon a trail of; or, by a singlectrl-o or``.
  • Types<Enter> at any time to repeat the last Sneak-search.
  • TypeS to search backwards.

Sneak can be limited to avertical scope by prefixings with acount.

  • Type5sxy to go immediately to the next instance of "xy" within 5 columnsof the cursor.

Sneak is invoked withoperatorsviaz (becauses is taken by surround.vim).

  • Type3dzqt to delete up to thethird instance of "qt".
    • Type. to repeat the3dzqt operation.
    • Type2. to repeat twice.
    • Typed; to delete up to the next match.
    • Type4d; to delete up to thefourth next match.
  • Typeyszxy] tosurround in brackets up toxy.
    • Type. to repeat the surround operation.
  • TypegUz\} to upper-case the text from the cursor until the next instanceof the literal text\}
    • Type. to repeat thegUz\} operation.

Install

Requires Vim 7.3+ orNvim. Label-mode requires Vim7.4.792+. With Nvim 0.5+ label-mode is driven byvirtual textinstead of the legacy "conceal" feature.

  • vim-plug
    • Plug 'justinmk/vim-sneak'
  • Pathogen
    • git clone git://github.com/justinmk/vim-sneak.git ~/.vim/bundle/vim-sneak
  • Manual installation:
    • Copy the files to your.vim directory.

To repeat Sneakoperations (likedzab) with dot.,repeat.vim is required.

FAQ

Why not use/?

For the same reason that Vim hasmotionslikef andt: common operations should use the fewest keystrokes.

  • /ab<cr> requires 33% more keystrokes thansab
  • Setsonly the initial position in the Vim jumplist—so you can explore atrail of matches via;, then return to the start with a singlectrl-o or``
  • Doesn't clutter your search history
  • Input is always literal (don't need to escape special characters)
    • Ignores accents ("equivalence class") when matching(#183)
  • Smarter, subtler highlighting

Why not usef?

  • 50x more precise thanf ort
  • Moves vertically
  • Highlights matches in the direction of your search

How dare you remaps?

You can specify any mapping for Sneak (see:help sneak).By the way:cl is equivalent tos, andcc is equivalent toS.

How can I replacef with Sneak?

mapf<Plug>Sneak_smapF<Plug>Sneak_S

How can I replacef and/ort withone-character Sneak?

Sneak has<Plug> mappings forf andt 1-character-sneak.These mappings donot invoke label-mode, even if you have it enabled.

mapf<Plug>Sneak_fmapF<Plug>Sneak_Fmapt<Plug>Sneak_tmapT<Plug>Sneak_T

Related

License

Copyright © Justin M. Keyes. Distributed under the MIT license.


[8]ページ先頭

©2009-2025 Movatter.jp