返回排行榜

justinmk/vim-sneak

Vim Scriptvim.org/scripts/script.php

The missing motion for Vim :athletic_shoe:

vimneovimnvimpluginmotionnavigationvimlneovim-pluginvim-plugin
Star 增长趋势
Star
3.5k
Forks
90
周增长
Issues
11
1k2k3k
2013年10月2018年1月2022年4月2026年7月
README

sneak.vim 👟

Jump to any location specified by two characters.

Sneak is a powerful, reliable, yet minimal motion plugin for Vim. It works with multiple lines, operators (including repeat . and surround), motion-repeat (; and ,), keymaps, visual mode, multibyte text, and macros.

Try label-mode for a minimalist alternative to EasyMotion:

let g:sneak#label = 1

Usage

Sneak is invoked with s followed by exactly two characters:

s{char}{char}
  • Type sab to move 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 (or s again, if s_next is enabled; see :help sneak).
  • Type 3; to skip to the third match from the current position.
  • Type ctrl-o or `` to go back to the starting point.
    • This is a built-in Vim motion; Sneak adds to Vim's jumplist only on s invocation—not repeats—so you can abandon a trail of ; or , by a single ctrl-o or ``.
  • Type s<Enter> at any time to repeat the last Sneak-search.
  • Type S to search backwards.

Sneak can be limited to a vertical scope by prefixing s with a count.

  • Type 5sxy to go immediately to the next instance of "xy" within 5 columns of the cursor.

Sneak is invoked with operators via z (because s is taken by surround.vim).

  • Type 3dzqt to delete up to the third instance of "qt".
    • Type . to repeat the 3dzqt operation.
    • Type 2. to repeat twice.
    • Type d; to delete up to the next match.
    • Type 4d; to delete up to the fourth next match.
  • Type yszxy] to surround in brackets up to xy.
    • Type . to repeat the surround operation.
  • Type gUz\} to upper-case the text from the cursor until the next instance of the literal text \}
    • Type . to repeat the gUz\} operation.

Install

Requires Vim 7.3+ or Nvim. Label-mode requires Vim 7.4.792+. With Nvim 0.5+ label-mode is driven by virtual text instead 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 Sneak operations (like dzab) with dot ., repeat.vim is required.

FAQ

Why not use /?

For the same reason that Vim has motions like f and t: common operations should use the fewest keystrokes.

  • /ab<cr> requires 33% more keystrokes than sab
  • Sets only the initial position in the Vim jumplist—so you can explore a trail of matches via ;, then return to the start with a single ctrl-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 use f?

  • 50x more precise than f or t
  • Moves vertically
  • Highlights matches in the direction of your search

How dare you remap s?

You can specify any mapping for Sneak (see :help sneak). By the way: cl is equivalent to s, and cc is equivalent to S.

How can I replace f with Sneak?

map f <Plug>Sneak_s
map F <Plug>Sneak_S

How can I replace f and/or t with one-character Sneak?

Sneak has <Plug> mappings for f and t 1-character-sneak. These mappings do not invoke label-mode, even if you have it enabled.

map f <Plug>Sneak_f
map F <Plug>Sneak_F
map t <Plug>Sneak_t
map T <Plug>Sneak_T

License

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

相关仓库
neovim/neovim

Vim-fork focused on extensibility and usability

Vim ScriptOtherneovimc
neovim.io
101.3k7k
junegunn/fzf

:cherry_blossom: A command-line fuzzy finder

GoGo ModulesMIT Licensefzfgo
junegunn.github.io/fzf/
81.9k2.8k
LeCoupa/awesome-cheatsheets

👩‍💻👨‍💻 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file.

JavaScriptnpmMIT Licensecheatsheetsjavascript
lecoupa.github.io/awesome-cheatsheets/
46.2k6.7k
helix-editor/helix

A post-modern modal text editor.

Rustcrates.ioMozilla Public License 2.0text-editorvim
helix-editor.com
45.5k3.6k
vim/vim

The official Vim repository

Vim ScriptVim Licensevimc
vim.org
40.7k6.1k
sxyazi/yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.

Rustcrates.ioMIT Licenseasyncioconcurrency
yazi-rs.github.io
40.5k946
lapce/lapce

Lightning-fast and Powerful Code Editor written in Rust

Rustcrates.ioApache License 2.0code-editordeveloper-tools
lap.dev/lapce/
38.7k1.3k
junegunn/vim-plug

:hibiscus: Minimalist Vim Plugin Manager

Vim ScriptMIT Licensevim
junegunn.github.io/vim-plug/
35.7k1.9k
NvChad/NvChad

Blazing fast Neovim framework providing solid defaults and a beautiful UI, enhancing your neovim experience.

LuaGNU General Public License v3.0nvimneovim
nvchad.com
28.4k2.2k
ycm-core/YouCompleteMe

A code-completion engine for Vim

PythonPyPIGNU General Public License v3.0vimcode-completion
ycm-core.github.io/YouCompleteMe/
25.9k2.8k
neoclide/coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.

TypeScriptnpmOtherautocompletionlanguage-client
25.2k957
syl20bnr/spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!

Emacs LispGNU General Public License v3.0emacsvim
spacemacs.org
24.6k4.8k