My Vim Tips

Very Useful Notes by Darin Brezeale

[Basic]
  • :cd
  • :pwd
  • :e foo.c    to edit another file
  • :e #        to jump back to the previous editing file
  • Ctrl+L      redraw whole screen

[Compile]
  • :make       invoke make, and jump to first line of error automatically
  • :set makeprg=gmake
  • :set makeprg=gmake\ \CC=gcc296
  • :clist  error list
  • :cfirst first line of error
  • :clast  last line of error
  • :cn     next line of error

[Buffers]
  • :buffers
  • :ls         list buffers
  • :bd         delete (close) a buffer

[Navigate]
  • :<num>      go to line <num>
  • ]] / ][     next { / } in the first column
  • [[ / []     previous { / } in the first column
  • %           jump to corresponding brace, #ifdef and #endif

[Bookmark]
  • m<a-z>      mark the position with the the single letter you supplied
  • '<a-z>      jump to the pos mark by the letter
  • ''          jump to the last jump pos

[Search]
  • /\t         search (and may highlight) <Tab>
  • *           search the keyword under cursor
  • #           search previous keyword under cursor
  • /<CR>       redo the last search
  • :set incsearch  incremental search
  • :set nois       disable incremental search

[Replace]
  • :s/<search>/<replace>
  • :25, 34 s/foo/bar/gc    replace 'foo' between line 25 and 34 with 'bar'
  •                         g for do it multi times per line
  •                         c for confirmation
  •                         region could also be selected in visual (block) mode and invoke through :s
  • :1, $s/foo/bar/g        global replace all foo with bar in current file
  • %s/foo/bar/g            same as above

[Highlight]
  • :set list   display non-printable chars
  • :set hlsearch   highlight matched items
  • :nohl           no highlight when search

[Ctags]
  • :set tags=<comma separated expression>  setup 'tags' file search path, usually './tags,tags,~/mytags'
  • Ctrl-]      jump to the definition of the symbol under cursor
  • Ctrl-T      jump back
  • :ta /foo    tag search for symbol 'foo', stop at the first match
  • :tn         tag search, next match
  • :tselect    select and jump from the tag list (also invoked through g then ctrl-])

[Macro]
  • q register    Start macro recording into the named register. For instance, qa starts recording and puts the macro into register a.
  • q    End recording.
  • @register    Replay the macro stored in the named register. For instance, @a replays the macro in register a.

你可能感兴趣的:(C++,c,C#,vim,Go)