http://www.tuxfiles.org/linuxhelp/vimcheat.html
File saving
:w filename Save changes to a file. If you don't specify a file name, Vim saves as the file name you were editing. For saving the file under a different name, specify the file name.
:wq Write the file and exit.
Navigating
0 To the beginning of a line.
$ To the end of a line.
b To the beginning of a word.
Deleting
dd or :d Delete the current line.
Copy Paste
y (V) Yank the highlighted text. In Winblows terms, "copy the selected text to clipboard."
d (V) Delete the highlighted text. In Winblows terms, "cut the selected text to clipboard."
yy or :y or Y Yank the current line. You don't need to highlight it first.
u Undo the last action
Ctrl + r Redo
Find
Find and replace
:%s/foo/bar/g Replace every occurrence of the word foo with bar in the whole file.
Searching for help
:help
:help .*open\&.*window ---
:help HelpForItem
vim , press Esc, press w to save the file ,q to quit
Working with files
:bn -- switch to the next file buffer
:bp -- switch to the previous file buffer
:ls -- list the opened file buffers
:buffer 17 --- go to the file with number 17 listed in the previous command
gf -- open the file under the cursor in Normal mode
:bd --- close the current file buffer
:e /var/tmp.txt open new buffer (and window ) with the /var/tmp.txt file
:new /path/to/the/file/to/open in
set winheight=90 (also could be added to /etc/vimrc
vim *.pl --- open all Perl scripts in the current directory
:cnext :bn -- go to the next buffer
:ls list all the buffers
:bn 3 -- go the nubmer of the buffer listed from the previous command
to Quit VIM :q
to delete the line in the executable mode – dd
:split /usr/share/some.file --- opens a new file in a new window
:e /usr/share --- opens a directory (in a new buffer , no windows to mess around )
:w filename Save changes to a file. If you don't specify a file name, Vim saves as the file name you were editing. For saving the file under a different name, specify the file name.
:wq Write the file and exit.
:q! exit without saving (the hyphen meaning is the same for all commands )
Navigating
/itemToSearchInTheText --- works without the colon also
j , k , l ,h
gg --- go the begining of the document
G -- go the end of the document
Home End Ctrl + Home Ctrl + End , Ctrl + vasen nuoli Ctrl + oikea nuoli Ctrl + G
495G --- go to row number 495
'' ---- (Press ' twice ) jump back to line (where you came from)
Ctrl + O --- Ctrl + I --- e - 0 To the beginning of a line.
$ To the end of a line.
b To the beginning of a word.
:/tokenToSearch n - N -
:?tokenToSearch n - Ctrl + o - Ctrl + i - N -
[](){} %
Deleting
dd or :d Delete the current line.
Copy Paste
y (V) Yank the highlighted text. In Winblows terms, "copy the selected text to clipboard."
d (V) Delete the highlighted text. In Winblows terms, "cut the selected text to clipboard."
yy or :y or Y Yank the current line. You don't need to highlight it first.
u Undo the last action
Ctrl + r Redo
Find and replace
:%s/foo/bar/g Replace every occurrence of the word foo with bar in the whole file.
:%s/^.*clear$\n//gi --- remove all the lines containing the string "clear"
where vim sets the settings of the "sessions"
vim /root/.viminfo
vim /home/sysadmin/.viminfo
vim /home/nortel/.viminfo
How to edit the colors of the current color scheme:
1. Check the name of your current color scheme located at: /root/.vimrc or /home/usrname/.vimrc (attention come kind of aliasing ... )
set colorsheme=dark
2. Edit the current colorsheme
/usr/share/vim/vim63/colors/darkblue.vim
/comments
3. Pick a HEX number for the color of the comments you would prefer to have .. #40FF00 (google color table )
Ctrl-R Ctrl-F Enters the file under the cursor into the editor in you commend line (command mode).
Ctrl-R Ctrl-A Enters the text from the editor in you commend line (command mode).
Mappings
the keyboard shortcuts performing user defined commands which could be saved at the /etc/vimrc
map
map
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!