theCAT
  
Report a Problem:
Email: support@cat.pdx.edu
Phone: 503-725-5420
  USERS PLATFORMS SYSTEM RESOURCES    
Home Students Fac/Staff CS Tutors Guidelines Windows Linux Unix Mac Mail Network Software Web TheCAT Sitemap
arrowHome arrow Unix arrow Vi Cheat Sheet Sunday, 22 November 2009  
Unix
Vi Cheat Sheet Print
Contributed by bkm   
Sunday, 09 October 2005
 Editing keys for VI editor

^ means hit the control key

All keys are active in the command mode, not the input mode.

^D Down 1/2 page ^0 Cursor to beginning of line

^U Up 1/2 page ^$ Cursor to end of line

^F Forward 1 page H Cursor to top of page

^B Backward 1 page M Cursor to middle of page

#G Go to line number # L Cursor to end of page

i Insert text before cursor

^G See current line number a Append text after cursor

[esc] Get VI to listen and I Insert at beginning of line

get out of insert mode A Append to end of line

^R Redraw the screen x Delete char cursor is on

^L Redraw the screen X Delete char before cursor

:q Quit, leave VI o Open line after current line

:w Write changes to file O Open line before current line

:wq Write, then quit dd Delete current line

- Cursor up 1 line cc Change current line

[ret] Cursor down 1 line r Replace next char with next

U Restore current line char typed

u Undo last change R Replace until [esc]

. Redo the last change s Substitute chars

[space] Cursor forward 1 char w W Cursor forward 1 word

[bksp] Cursor backward 1 char b B Cursor backward 1 word

) Cursor forward 1 sentence e E Cursor to end of current word,

( Cursor backward 1 sentence or to end of next word

fx Find next x on current line /text Search forward for "text"

Fx Find previous x on current ?text Search backward for "text"

line n Repeats previous search (next)

; Repeat last search N Repeats previous search, but

, Repeat last search, but in in opposite direction

opposite direction > Shifts text right

t T same as f and F, but stop < Shifts text left

before char, not on it The arrow keys move the cursor.

d* Deletes whatever replaces the "*". (movement commands)

- [return] [space] ^ $ 0 H L M w b e W B E ( ) f F t T ; , / ? n N are

the movement commands that can be used with d (also called targets).

c* same as d*, but changes instead of deleting.

p Put - Inserts the most recently deleted text after the current line or

char. Can put several times to make copies.

P Put before the current line or cursor.

yy Yank - Pick that does not delete. Use p or P to put the yanked stuff.

The "y*" command can use any targets that "d*" and "c*" can use.

m[a-z] Set a mark, up to 26 ([a-z]) different marks.

'[a-z] Go to named mark.

"[a-z]yy Yank to named buffer, up to 26 ([a-z]) different buffers.

"[a-z]p Put from named yanked buffer.



:set sw=n or Set the shiftwidth (for < and >) to n.

:set shiftwidth=n

:set nu See line numbers

:set ai Automatically indents next line the same amount as

:set autoindent the current line.

^D Detab - Moves to left of line started with autoindent. Must be in

insert mode.

:set noai Turns off autoindent.

:set noautoindent

! Filter that allows you to execute shell commands from within VI. Can

take any targets like "d*", "c*", "y*", ">", "<".

: Allows access to the "full power" of the editor EX.

:r [filename] Inserts the file [filename] at the current line.

Q Go into the editor EX. Gives you a permanent ":" at bottom of screen.

:vi Return to the VI editor from EX.

:n Go to next file. (Enter VI with "vi file1 file2..."

:n! Go to next file, without saving changes.

:e [filename] Edit another file.

:e! Edit same file from last save.
Last Updated ( Wednesday, 08 March 2006 )
Intel Lab - Fab 55-17
Intel Lab - Fab 55-17
Upcoming Events
There are no upcoming events currently scheduled.
View Full Calendar

©1999 - 2009 TheCAT