LAMP

My tryst with Web Development

Thursday, January 20, 2005

Vim Shortcuts

Based on a list compiled by Charles E Campbell, Jr.,12/99. Updated by Alan E Klietz 1/2005.

Important/frequently used commands are boxed.

-b binary mode

-n no swap file; use memory only

-r recover aborted session via swap file

-R readonly mode

-V[N] verbose mode (to troubleshoot .vim scripts)

: enter Command Mode

Esc return to Normal Mode

. repeat the last command

% jump to matching parenthesis, brace, or bracket

'a jump to line with mark a. See m.

( jump to previous sentence

) jump to next sentence

0 goto beginning of line

$ goto end of line

+ goto first character of next line

, reverse direction of last f, F, t, or T

- goto first character of previous line

/ search forward for text, / to repeat

? search backward text, ? to repeat

* search for word under cursor N times

# same as *, but search backwards

& synonym for ":s//~/" (repeat last substitution)

; repeat last f, F, t, or T

={motion} filter {motion} lines through 'equalprg' external program

@ execute command in register

[( goto previous unmatched '('

[[ previous section

[] go backwards count sections or to previous '}' in 1st column

[{ goto previous unmatched '{'

[# goto previous unmatched "#if" or "#else"

[* goto previous start of a C comment (/*)

[i display 1st line that contains keyword under cursor

[I display all lines that contain keyword under cursor

[^I jump to 1st line that contains keyword under cursor

[d display 1st macro definition that contains macro under cursor

[D display all macro definition that contain macro under cursor

[^D jump to 1st macro definition that contains keyword under cursor

][ go forwards count sections to to next '}' in 1st column

]] next section

]} goto next unmatched '}'

]# goto next unmatched "#if" or "#else"

]* goto next end of a C comment (*/)

]i like '[i', but start at current cursor position

]I like '[I', but start at current cursor position

^] jump to file having tag under cursor. See ^t

]^I like '[^I', but start at current cursor position

]d like '[d', but start at current cursor position

]D like '[D', but start at current cursor position

^ first non-whitespace character

_ move (count-1) lines downward on first non-blank character

` goto mark

{ previous paragraph

| to screen column [count] in current line

} next paragraph

~ switch case of current character

'' go to start of line of previous mark or location before search

`` return to previous mark or location before a search

"return key" next line

"spacebar key" next character

!!{filter} filter [count] lines through the external program {filter}

!{cmd}{filter} send {motion} text through external program {filter}

!!scramble toggle encryption of C/C++ string (AEK)

<’a shift left up to mark

<% shift left until matching (, [, or {

<< shift line one shiftwidth to the left

>’a shift right up to mark

>% shift right until matching (, [, or {

>> shift line one shiftwidth to the right

a append after the current location

A append at the end of the line

^a add [count] to the number at or after the cursor

b beginning of previous word

B beginning of previous word, ignore punctuation

^b scroll back one screen; see ^f

c delete {motion} text (into register) and begin insert

C change to end of line

^c ends insert mode, unused in command mode

d{motion} delete text covered by a {motion}

d’a delete up to mark

Ndd delete N lines

D delete to end of line

^d scroll down half a window (N^d sets new default); see ^u

e end of word

E end of word, ignore punctuation

^e scroll screen down one line

fx find given character forwards

F find given character backwards

^f scroll forward one screen; see ^b

g^g show information about current cursor position

g^h start Select block mode

g^] :tjump to tag under the cursor

g# like "#", but without using "\<" and "\>"

g$ wrap off: goto rightmost onscreen character of current line

g* like "*", but without using "\<" and "\>"

g0 wrap off: goto leftmost onscreen character of current line

g? rot13 encoding operator

g?? rot13 encode current line

g?g? rot13 encode current line

gD goto definition of word under cursor in current file

gE go backwards to end of previous WORD

gH start Select line mode

gI like "I", but always start in column 1

gJ join lines without inserting space (like :j!)

["x]gP put text (from register x) N times

gR enter virtual replace mode

gU{motion} make Nmove text uppercase

gV don't reselect previous Visual area (maps, menus) in Select mode

g] :tselect on tag under cursor

g^ wrap off: goto leftmost non-white onscreen char on current line

ga print ascii value of character under cursor

gd goto definition of word under cursor in current function

ge go backwards to end of previous word

gf start editing file whose name is under cursor

gg cursor to line N (default: 1) ; start Select mode

gh start Select mode

gj wrap on: like "j", but go N screen lines down

gk wrap on: like "k", but go N screen lines up

gm goto character at middle of screenline

go cursor to byte N in buffer

["x]gp put text (from register x) after cursor N times

gq{motion} format text

gr{char} virtual replace N chars with given char

gs goto sleep for N (1) seconds

gu{motion} make Nmove text lowercase

gv reselect previous Visual area

g~{motion} swap case for Nmove text

g{Down} same as gj

g{End} same as g$

g{Home} same as g0

g{LeftMouse} same as g{LeftMouse}

g{RightMouse} same as g{RightMouse}

g{Up} same as gk

G goto line (100G); defaults to EOF

^g show status line

h left

H goto first line on screen

^h backspace in insert mode, left in command mode

i insert before current location (until Esc)

I insert before first non-whitespace character on line

^I goto [count] cursor position in jump list

j down

J join next line with current line

^j down in command, create newline in insert mode

0 Comments:

Post a Comment

<< Home