Vim (vi) usage tips and shortcut


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home2/namranco/public_html/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Ok. I had been introduced to “Vim” (vi) quite few years ago… i think was 2005?
Before that I was using “pico” which is meant for pine or reading email client if not mistaken.
At that time , i was hardly know how to use vi .
remembering how did i always messed up whenever tried to edit cronjob using
“crontab -e” . it spawn the default editor instead of pico.
most of the system i used by then was vi..

First few attempt was the following sequence :

 
vi  file.txt
 
:q! - quit without change
i - insert 
:w - write to file
:wq - write to file and quit
:wq! - write and quite with override option..
doesn't care if file is not written due to permission or  anything.
 (that time got no sense of file permission yet.. haha)


then ..

vim -r file.txt - recover from a .swp file?
view file.txt - just view the file without altering it.. 
as someone else is also accessing the file.
y - for yank
d - delete
p - for paste.
 
3yy - for three line copy 
r - for replace
v - for visual mode.
i - for insert mode.

then ..

:%s/texttomatch/replacewiththis/g  - for replacing thing
gg - go to top most of current file
G - go to most bottom?

then few week back.. learnt the following..

:split .  - split the screen horizontally with the current folder content.. which is clickable.


to move between the splitted window
ctrl+w

:vsplit . - split the screen vertically .. with current folder.


shift+v – to start line selection. (change to visual mode)

then followed by down arrow to highlight the line.
press y to yank..highligted line.
then move the cursor to where to put..
press p to paste..

 
% - to find the next closing bracket.
u - to undo
 
ctrl+r - to redo
 
:set ai -  turn on auto-indent
:set noai  - turn off auto-indent .. useful whenever pasted from other window.

and also the ~/.exrc with the following content.

set ts=2
set shiftwidth=2
set ai
set background=dark

I believe there are many more usage…
let’s collect it before I forgot how to use them

Related Post

One Response

  1. Bonnet5Stiern says:

    The rugged look of fringe remains popular, while the feel of leather instills a natural style.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *