Thursday, January 29, 2009

Vim - basics - copy-paste

Useful shortcuts for Vim beginners: 

mark text 
v ... start highlighting text 
+y ... end highlighting text 

d ... cut 
P ... P-paste above cursor 
p ... paste below 

u ... undo 
Ctrl+R ... redo 
source: source web 
other: other web 
Vim macro for copy-paste with Ctrl+C and Ctrl+W: abclinuxu.cz (Czech version)

VI shourtcuts:

Go to
Shift g    = end of file
gg    = start beginning of file
GG    = start of file
:22    = go to line 22
0 = start of line
^ = first letter on line
$ = end of line

Copy to buffer
:t.    = duplicate line
:t7 = copy line after line 7

yy = copy current line
ayy = copy current line to buffer a
a5yy = copy 5 lines into buffer a

Paste from buffer
y7yp = copy and paste 7 lines
p = paste line
ap = paste buffer a at the cursor


Search
n = search next
N = search previous
* = go to next occurrence of word under cursor
# = go to previous occurence

Less shortcuts

NoHup
# Nohup process id pid :
nohup my_command > my.log 2>&1 &
echo $! > save_pid.txt

No comments: