VI File Editor
There are a variety of text editors in the Linux operating system. Among them, particularly the most commonly used by database administrators is the VI text editor. It designed specifically for LINUX / UNIX systems. Although it may seem complicated for beginners, with the speed of VI, we made it easy for database administrators. VI What is so special, you run the command as well as writing and write to the user at the same time. When you first start the VI editor will enter command mode. To switch to text mode “i” or “a” letter of the need to press. Again you have to press the ESC key to switch to command mode. Now lets know the VI editor shortcuts;
Open an existing file or create a new file with VI:
$vi file_name.txt
@Not: $ -indicates that the command will be executed on linux.
do not write in the command line with the $ sign
Text
To get (insert) mode:
Add text to beginning of the line |
I |
Add text to the cursor to where |
i |
Open new line above the cursor |
O |
Open new line below the cursor |
o |
Add text after cursor |
a |
Add text to the end of line |
A |
To get command mode <ESC>
Cursor moving operations (In command mode):
Move the cursor to the left |
h |
Move the cursor to the left 3 characters |
3h |
Move the cursor down |
j |
Move the cursor up |
k |
Move the cursor to the right |
l |
Move the cursor to the last line |
G |
Move the cursor to line number N (for example, go to line 3, 3G) |
nG |
Move the cursor to line number n (for example, go to line 5) |
:5 |
Move one word to the right |
w |
Move one word to the left |
b |
Move to end of line |
$ |
Move to end of line |
End |
Text deletion operations (In command mode):
Delete the line on the cursor |
dd |
Delete 4 lines |
4dd |
Delete the string to end of line |
D |
Delete the character on the cursor |
x |
One character displacement |
r |
Delete a word |
dw |
Change a word |
cw |
Editing operations (In command mode):
line copy |
yy |
3-line copy |
3yy |
Paste upper the cursor |
P |
Paste under the cursor |
p |
To copy telefon.txt file to working text from the cursor location |
:r telefon.txt |
Backward-text search |
?kelime |
A forward-text search |
/kelime |
Place in the next occurrence of the word |
n |
Command to undo a previous run |
u |
Undo all changes applied to the row |
U |
Finds oldstring and replace it with newstring |
:%s/oldstring/newstring/cg |
File saving operations (In command mode):
Save changes |
:w |
Save and exit from vi |
:wq |
Exit without saving |
:q! |
Save file as new file |
:w file |
Talip Hakan Ozturk