Sunday, July 19, 2015

VIM

Vim is simply an improved version of Vi. It pretty much has a ton of stuff that Vi doesn’t.

Within Vim you can see the differences between Vi and Vim by running the following command  :h vi-differences.

root@MR-X:~$ Vi
[It will create a Blank file.]

root@MR-X:~$ Vi
[It will create multiple file at once.]

root@MR-X:~$ Vi file1.txt
[to open file1.txt using Vi]
[press i  - to insert text in file1.txt]
[press Shift+: and then type wq  to save and quit.
            : q  to exit without any changes in file
            : x  to save changes and exit.]




VIM

Quitting


:x - exit, saving changes
:wq - exit, saving changes
:q - exit, if no changes
:q! - exit, ignore changes 

Inserting text 


i - insert before cursor
I - insert before line
a - append after cursor
A - append after line
o - open new line after cur line
0 - open new line before cur line
r - replace one character
R - replace many characters 

Motion


h - move left
j - move down
k - move up
l- move right
w - move to next word
W - move to next blank delimited word
b - move to beginning of the word
B - move to beginning of blank delimited word
e - move to end of word
E - move to end of blank delimited word
( - move a sentence back
) - move a sentence forward
{ - move paragraph back
} - move paragraph forward
0 - move to beginning of line
$ - move to end of line
nG - move to nth line of file
:n - move to nth line of file
G - move to last line of file
fc - move forward to 'c'
Fc - move backward to 'c'
H - move to top of screen
M - move to middle of screen
L - move to bottom of screen
% - move to associated (),{},0 

Deleting text


x - delete character to the right
X - delete character to the left
D - delte to the end of line
dd - delete current line
:d - delete current line 

Searching


/string - search forward for string
?string - search back for string
n - search for next instance of string
N - for for previous instance of string 

Replace 


:s/pattern/string/flags - replace pattern with string, according to flags
g - flag, replace all occurences
c - flag, confirm replaces
& - repeat last :s command

Files 


:w file - write to file
:r file - read file in after line
:n - go to next file
:p - go to previous file
:e file - edit file
!!cmd - replace line with output of cmd 

Other 


u - undo last change
U - undo all changes to line

No comments:

Post a Comment

Evil Twin attack

Evil Twin Attack is attack is frequently carried upon wireless access points with malicious intentions. This attack happens when...