VI Navigation [escape key = ]
0 [zero] = Move to beginning of line
G = Go to end of file
5G = Move to beginning of 5th line
u = Undo
. = Repeat last command
x = Delete character
dd = Delete line
dw = Delete word
d$ = Delete from cursor to end of line
$ then J = Join/append following line with current
$ then a = Append input at end of line
A = Append input at end of line [same as above, but one less key stroke]
i = Insert text at cursor
/ = Bottom of screen type search string and will move
cursor to first occurrence
Replace text
. :1,$s /and/AND/g
^^^^^ ^ ^ ^
||||| | | |
||||| | | \----------- Globally
||||| | \-------------- Replace with
||||| \------------------ Find
|||||
||||\---------------------- substitute for text
|||\----------------------- To last line
||\------------------------ separator
|\------------------------- From line "1"
\-------------------------- ":" operator to start command processing
Useful tid bit to remove EOL characters from DOS file
[use key sequence "" together for EOL char]
:%s/^M$//
Write lines to new file
:1,10w abc [puts lines 1~10 into file abc]
Change working file from current to file abc [be sure to save first]:e abc
Read abc file into working file after cursor:r abc
Execute command from prompt
:!cmd [where cmd is could be a bash command]
Example -> :r !date [inserts time and date at prompt]
From online wiki resource: http://en.wikibooks.org/wiki/Linux_Guide/Using_the_shell
No comments:
Post a Comment