Thursday, September 13, 2012

How to navigate in Terminal command line and in VIM on Mac OSX

TERMINAL commands in MAC OSX 
Ctrl + a (takes you to the beginning of the line)
Ctrl + e (takes you to the end of the line)
Alt or Option + (left arrow) or (right arrow) move back by 1 word (the alternative is Esc + b or Esc + f --  I have to retype Esc + b *each time*)

Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
Alt + F Move cursor forward one word on the current line
Alt + B Move cursor backward one word on the current line
Tab Auto-complete files and folder names

VIM commands in MAC OSX 
ctrl-FMove forward one screen.
ctrl-BMove backward one screen.
$Move cursor to end of line.
^Move cursor to beginning of line.
:1Move to first line of file
:$Move to last line of file
/Search for a character string.
?Reverse search for a character string.
xDelete the character at the cursor position.
ddDelete the current line.
pPaste data that was cut with x or dd commands.
uUndo.

Entering Input Mode
aAdd text after the cursor.
iInsert text before the cursor.
RReplace text starting at the cursor.
oInsert a new line after the current one.
Entering Command Mode
escSwitch from Input mode to Command mode.
Exiting or Saving Your File
:wWrite file to disk, without exiting editor.
ZZSave the file and exit.
:q!Quit without saving.

No comments: