Vim Cheat Sheet for Programmers May Be Freely Distributed! Http:/Michael.Peopleofhonoronly.Com/Vim/ Sept

Vim Cheat Sheet for Programmers May Be Freely Distributed! Http:/Michael.Peopleofhonoronly.Com/Vim/ Sept

Revision 2.0 Vim 7.3+ Copyleft © 2011 Esc Normal Vim Cheat Sheet for Programmers May be freely distributed! http:/michael.PeopleOfHonorOnly.com/vim/ Sept. 11, 2011 :version Sharing is Caring. HOW-TO make Vim not suck Out of the Box: :help statusline :set nocompatible ruler laststatus=2 showcmd showmode number Search :set incsearch ignorecase smartcase hlsearch Remove useless splash screen :set shortmess+=I Best tips: http://vim.wikia.com/ Best scripts: http://www.vim.org/scripts/index.php :map <F9> :e $HOME/_vimrc<CR> :map <F6> :so $HOME/_vimrc<CR> Ctrl ` Ctrl 1 Ctrl @ Ctrl 3 Ctrl 4 Ctrl 5 Ctrl ^ Ctrl 7 Ctrl 8 Ctrl 9 Ctrl 0 Ctrl _ Ctrl = play prev goto next begin end ~ toggle case extern filter soft repeat :s cur line ! @• macro # identifier $ ⇥ % match ^ ⇤ & * identifier ( sentence ) sentence _ + ↓ 13 1 3 8 auto- 2 `• goto mark hard 1 2 3 4 5 6 7 8 9 0 ⇤ - ↑ = format 14 block select ^w• window… scroll line ↑ 12 :redo 10 ctags return scroll line ↓ half page ↑ Ctrl I prev mark 9 ↑ Normal ctags identifier end ↖ paragraph ex mode WORD ↘ Replace ← until char copy line undo line insert open ⤒ paste ⤒ Q W E WORD ↘ R T• Y U I ⇤ O P { paragraph } ↘ record end replace 0 0 Tab until char → 2 open ⤓ paste ⤓ word ↘ copy undo ↱ insert misc. misc. q• macro w e word ↘ r char t• y u i o p [• ]• 7 incr. # 10 half page ↓ page ↓ file/cursor info Ctrl H 15 Ctrl J redraw Ctrl ; Ctrl ' Ctrl \ goto eof / man page Bottom 0 ⇤ A append ⇥ S subst line D del ⇥ F• ← find char G H Top screen J Join lines K L : cmd line "• register | goto line# identifier screen goto col# ↰ 0 6 "next" 16 goto mark \ Caps a append s subst char d del 2 f• find char → g• extra h ← j ↓ k ↑ l → ; '• \• f/F/t/T ⇤ 7,11 9,16 15 Ctrl ^ :suspend decr. # Normal / Cancel block select page ↑ ↓ Ctrl M Ctrl , Ctrl . Ctrl / Unused & Duplicate keys 4 select "prev" Middle 2 2 \ Ctrl-K Ctrl-S (free) Z• quit X ← del char C change ⇥ V B ↖ WORD N M < undent > indent ?• find ↖ Ctrl-L (redraw) Shift ⇧ lines find screen 13 ` near dup of ' 5 0 select find "prev" 16 repeat 14 Ctrl-Q = Ctrl-V extra del char → change 2 ↖ word set mark find ↘ z• x c v chars b n "next" m• , f/F/t/T . cmd /• 15 Ctrl-J = Ctrl-M = ^N Legend: 16 The search direction is relative; next is the initial direction, previous is the opposite direction. n ; repeat same initial direction find. N , repeat opposite initial direction find. Note: ; , only searches cursor line, n N searches buffer. Macro Register name (0-9a-zA-Z) required :help cmdline :r file insert file Tags \ :map \ :Explore<CR> manually type <,C,R,> :buffer # Op Motion req.; act between cursor & dst :w save :gui switch to GUI :ts list active tags §0 "• before del/copy/paste to use register :buffers list files Cmd Command :q quit :q! quit w/o save ^] jump to tag under cursor "+x cut to system clipboard reg. '+' :new blank file/buffer Ins Command and enter insert mode :e <file> edit file in new buffer ^t restore cursor before tag jump "+gP paste from system clipboard :bn next file Move Moves cursor or defines range for op :source % exec cmds in cur file ^p complete word 1 Number before any action repeats it :bp prev file Find Search (↖ = reverse, ↘ = forward) :exec '...' do cmd :ta Foo manual jump to tag 'Foo' 2p paste twice 3. repeat thrice :bd close file tag ctags / diffs / folding :help movement 2 Repeat op to act on current line :bd!force close Code Code formatting, whitespace, etc. soft ^ ⇤ Start of Line 1st non-whitespace Diff yy copy line dd del line :set lines=# Extra Extended functionality; req. extra chars hard 0 ⇤ Start of Line column 0 [c prev diff :hi DiffAdd guifg=#rrggbb << undent line >> indent line :set columns=# • Char arg req. g z Z ^w ' " ` … $ ⇥ End of Line ]c next diff :hi DiffChange guibg=#rrggbb 3 # highlight words under cursor :winpos # # GUI Modes :help modes | move col 0 #| move col # :diffupdate :hi DiffText gui=none 4 ZZ save & quit ZQ quit w/o save Windows n Normal Esc ^[ ^c ^b page ↑ ^f page ↓ resync :hi DiffDelete 5 zz center cursor line in window :help windows i Insert a i r s ^u ½ page ↑ ^d ½ page ↓ zh scroll left zl scroll right ^w• or :wincmd • v Visual v V ^v ^q ^e scroll line ↑ ^y scroll line ↓ Folding Changes zt scroll top zb scroll bottom w! :switch to next o Op pending c d y < > 1g start of file 0g end of file zR fold remove :changes §6 gg top of file c! :close! c Command Line : / ? ! #g goto line # G end of file zo fold open g; older change gf open file under cursor n! :new s! :split horz. Foo [[ zc g, ^a word ( src , ␢ dst , ␢ len ); begin this func { fold close newer change 7 incr # under cursor (Dec / Hex) v! :vsplit vertical Note: There is no whitespace in-between 'Foo(src,' but before/after 'dst,' ]] begin next func { zi invert all ^x decr # under cursor (Dec / Hex) o! :only maximize WORD Foo ( src , ␢ dst , ␢ len ); :set matchpairs=(:),{:},[:],<:>,?:\: zr fold reduce Syntax 8 * start a "new" search =! all same size Startup % goto matching { } < > [ ] zm fold more :syntax enable Insert mode h! move to win ← j! move to win ↓ vim <filename> +123 :set filetype= ^p ^n goto line 123 :help range 9 prev auto-complete next k! move to win ↑ vim <file> … -t Foo edit at tag 'Foo' :s/Foo/Bar find Foo replace w/ Bar :help recording c cpp sh make perl python 10 ^d undent ^t indent l! move to win → vim <file> … -c "/Foo" cmd: find 'Foo' & edit :s/Foo/Bar/g ...all instances on line q• start recording Note: chose only ONE type! §11 ^x• ^f filename completion :sp! [<filename>] GUI vim -g or gvim start GUI ver. :%s/Foo/Bar apply to whole file @• playback Convert <eol> ^s spelling :set spell! edit in split window GUI Linux :set guifont=ProggyTinyTT\ 12 .,.+# cur line, cur line + # lines q stop recording :set fileformat= ^k dictionary ]s next bad Cursor Bookmarks GUI OSX :set guifont=ProggyTiny\:h11 $ last line '< start of select @@ repeat unix or dos or mac ^t thesaurus :help spell :marks ` ' ^o diff gvimdiff <file1> <file2> [<file3>] '> end of select then :w to convert 12 ^r• paste register 0-9a-zA-Z or … ma mark local 'a' bug Broken Keys Ctrl-I = Tab, Ctrl-[ = ESC Code = < > << >> :set tabstop=# set tab stop every #th col + clipboard (or '*') :help c_CTRL-R 'A goto global 'A' Vim is still unable to map certain keys for your own use… :set backspace=indent,eol,start :set expandtab! toggle hard/soft tabs " last del/copy % filename '' prev location § Caps, Ctrl-1, Ctrl-Shift-1, Ctrl-I, Ctrl-\, etc. allow backspace join lines :set listchars=… tab:>-:trail:-,nbsp:%,eol:$ :set numbers! toggle line numbers File / Directory 0 See: src/ops.c -c "/valid_yank_reg" for "• reg. names :set shiftwidth=# indent width for ai :set list! toggle whitespace :set wrap! toggle linewrap display :Explore or :e . 6 See: src/normal.c -c "/nv_cmds" for g• extra cmds :set autoindent! toggle auto-indent :set colorcolumn=80 visible right margin indicator :set showmatch highlite matching () :set browsedir=… 11 See: src/edit.c -c "/ctrl_x_msgs" for ^x• insert cmds :set lisp lisp indent mode noremap + :s/^/\/\//<CR> block comment noremap - :s/^\/\///<CR> uncomment one of buffer last .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us