<<

The Back Side — Extensions Extra motions Folding jump to beginning, end of {} block [{ ,]} To working with a file convenient, multiple lines same for parentheses [( , ]) may be “folded” together into a single highlighted line. Use Visual same for / (–style comments) [/ , ]/ this to get long sections out of the way while editing. Probably the useful extension in Vim is visual mode. previous end of word, space–delimited ge, gE It allows you to highlight a region of text for the applica- create, delete a zf, zd tion of an editing or “colon” . open, (re–)close a fold zo, zc Extra markers remove outermost folds, more folds zr, zm highlight by character v Marks set with capital letters are “global”; jumping to a remove all, re–fold all folds zR, zM highlight by line V global mark may take you to a different file. Several marks disable, (re–)enable, toggle folds zn, zN, zi highlight by column C-V are remembered between editing sessions: save, load view (including folds) :mkview, :lo re–select previous visual area gv position when file was last open ’" position where file was last edited ’. Compiling and source code Windows file and position of last Vim session ’0 There are several commands for facilitating software de- Even on text consoles, Vim allows the editing environment velopment: to be divided into separate windows may contain the same or different files. Commands that open a new Other searching correct indentation of line == incremental search :set (no)incsearch window take an optional file argument. increase the indent level >> highlight search :set (no)hlsearch decrease the indent level << open new horizontal window :new ignore case in search :set (no)ignorecase window horizontally :split find word under cursor fwd, back *,# run make and move cursor to first error :make split vertically :vsplit move to next, previous error :cnext, :cprev close current window :close Interface and colors move to first, last error :cfirst, :clast close all but current window :only syntax coloring :syntax on view error or list of errors :cc, :clist cycle to next window C- w switch to graphical :gui list lines with identifier under cursor [I cycle to previous window C-W p make windows equal height, width C-W = , C-W | show line numbers :set number Using decrease, increase height one C-W - , C-W + show commands in progress :set showcmd You must first run ctags or etags on your file to use these decrease, increase width one C-W < , C-W > show matching bracket :set showmatch features. autoindent :set ai jump to function with tagname :tag tagname Objects smartindent :set si jump to tag under cursor C-] In addition to the usual motions that are supported by file format (dos, , mac) :set ff=... previous tag C-t , Vim supports several objects: word, sentence, para- good for editing tables :set virtualedit=all , and block. These are used with editing commands edit option set :options Other (delete, change, and yank). The advantage over motions is reformat margins gq that you do not have to be one end of an object to use Insert mode editing make case upper, lower, toggle gU, gu, g~ it. For example will delete a sentence from anywhere das There are some commands available while in insert mode: add subtract from number under cursor C-A , C-X within it. copy from line above, below C-Y , C-E edit file under cursor gf a word, a sentence, a paragraph aw, as, ap complete from previous match C-P view under cursor K same without white space (inner) iw, is, ip insert from () register C-R print highlighted copy :hardcopy blocks delimited by [ ], (), <>, and {} a[, a(, a<, a{ insert digraph C-K di list digraphs :digraphs same without surrounding brackets i[, i(, i<, i{ execute single command C-O command editable command q: