模式 Package Manager Vimscript Vim CLI arguments refs 在Finder中使用NeoVim打开文件

Movement

You should spend most of your time in Normal mode, using movement commands to navigate the buffer. Movements in Vim are also called “nouns”, because they refer to chunks of text.

  • Basic movement: hjkl (left, down, up, right)
  • Words: w (next word), b (beginning of word), e (end of word)
  • ==Lines: 0 (beginning of line)==, ^ (first non-blank character), $ (end of line)
  • ==Screen: H (top of screen), M (middle of screen), L (bottom of screen)==
  • ==Scroll: Ctrl-u (up), Ctrl-d (down)==
  • File: gg (beginning of file), G (end of file)
  • Line numbers: :{number}<CR> or {number}G (line {number})
  • Misc: % (corresponding item)
  • Find: f{character}t{character}F{character}T{character}
    • find/to forward/backward {character} on the current line
    • , / ; for navigating matches
  • Search: /{regex}n / N for navigating matches

Multi-Windows

Split Windows

  • Split horizontally with same buffer: <C-w>s
  • Split vertically with same buffer: <C-w>v
  • Split horizontally with new file: :sp[lit] {file}
  • Split vertically with new file: :vsp[lit] {file}
  • Loop: <C-w>w
  • To left: <C-w>h
  • To right: <C-w>l
  • To top: <C-w>k
  • To bottom: <C-w>j
  • Enable navigate using mouse: set mouse=a

Close window

  • Close active window: :clo[se] | <C-w>c
  • Close all other windows: :on[ly] | <C-w>o

Move window

  • Make all window congruent: <C-w>=
  • Maximize active window height: <C-w>_
  • Maximize active window width: <C-w>|
  • Set current window height to N lines: [N]<C-w>_
  • Set current window width to N lines: [N]<C-w>|

Settings

" expand tab to 4 spaces
set expandtab shiftwidth=4 softtabstop=4

Plugins

ctags

  • To jump to definition, use <C-]> (jump to first definition). Use <C-t> to jump back.
    • This is also available as :tag <tag> <RET>
    • use :tn and :tp to jump to other definitions
  • You can also use g ] (list all definitions) if a symbol is ambiguous.
  • To autocomplete, use <C-x><C-]> or <C-x><C-o> (autocomplete tag and omnicomplete, respectively).
  • Use :ts <symbol name> <RET> to search for a symbol.
  • You can set the tags setting to the paths of the tags files you want to use.

More info: