This blog mainly having articles about Git Version Control and Ruby on Rails web framework. People may want to follow my blog one who learn very basic/Beginners about Git and RoR Technologies Tips.
Wednesday, 9 January 2013
Linux Vi editor basic commands
This article will help you, if you are very beginner in Vi editor in Linux platform.
Here is the list of commands for your reference.
* Cursor movement commands
h - left side single character move
j - down by one line from current cursor position
k - Up one line above from the current cursor position
l - Right side single character move
* file Edit commands
* vi +5 <file name> - It will open the file then the cursor position will stay on line no 5( 5 is just example only)
* Search related commands
* vi +/string - It will open the file and search the given string after that cursor will stay on first occurrence of the given string.
* /<string> - It will find a string in the forward way. If you want to next find then press "n"
* ?<string> - It will find a string in backward way. similarly if you want to find next then press "n"
* Insertion commands
o(alphabetical letter) - It will insert one line below the current cursor position.
O(alphabetical letter) - It will insert one line above the current cursor position.
* Delete commands
dd - It will delete one line from your current cursor position.
5dd - It will delete 5lines from your current cursor position.(5 is just example only)
* Copy commands
yy - It will copy current cursor line.
5yy - It will copy 5 lines from current cursor position line.(5 is just example only)
* Paste command
p - It will paste whatever you copied.
* Word jumping/movement
w - it will move one word to next word (cursor position will be at starting of the string)
b - Back to previous word (cursor position will be at starting of the string only)
e - Move to next word (cursor position will be end of the next word)
* Goto Line no :
ESC then type :<line no>
NOTE : WHENEVER YOU DO THIS COMMANDS BETTER PRESS "ESC" COMMAND TWICE THAT FOR YOU ARE MAKE SURE YOU ARE IN COMMAND MODE. THAN ONLY THE ABOVE COMMANDS WILL EXECUTE.