vim tips
2009-01-17 23:01
337 查看
In my mind, vim is one tool, just to use it and be an expert step by step if needs.
---------------------------------------------------------
First step: open and edit
To one newer, we only need to know little commands to use vi/vim. There are 2 modes when we start it.
-- command mode : it is default mode, and we can't input characters as other text editors. We can input commands in this mode.
-- insert mode: we can edit text.
To switch from [command mode] to [insert mode], press "i".
To return [commnad mode], press "Esc"
There are some other modes in some documents, don't care about them. The others can be classified into [command mode] in someway.
Now, there are some useful commands in the [command mode]
--"dd", delete current cursor line
--"yy", copy current cursor line
--"nx", n is a number(1, 2, ....), delete n characters from the cursor
--"p", paste. maybe to below line for one line, maybe to follow the current cursor for characters
--"h"/"j"/"k"/"l", h: move left, j: move down, k: move up, l: move right. in the lastest version, the direction arrows work also.
--":q!" quit vim without save
--":w"/":wq" save(/save and quit) file
--"/words" search word, words respresents the string
Now we can edit file thought without efficiently.
---------------------------------------------------------
Further step: tips
--ctags
installation: don't use the package "elvis-tools", use the "exuberant-ctags"
preparation: to create one tags file for vim
---ctags -R *
---:set tags=tagsfilepath
usage:
---ctrl+] goto the defination
---ctrl+o go back
--plugins
To install plugin, just put vim file into ~/.vim/plugin, and help text to ~/.vim/doc. Use :helptags ~/.vim/doc in vim to create helps.
Here is one alternate plugin, it is useful, it was written by Michael Sharpe
please refer to: http://www.vim.org/scripts/script.php?script_id=31
A few of quick commands to swtich between source files and header files quickly.
:A switches to the header file corresponding to the current file being edited (or vise versa)
:AS splits and switches
:AV vertical splits and switches
:AT new tab and switches
:AN cycles through matches
:IH switches to file under cursor
:IHS splits and switches
:IHV vertical splits and switches
:IHT new tab and switches
:IHN cycles through matches
--switch in files
--:e filename add new file into buffer
--:bn/bN switch to next/previous file
--:b(number) switch to nth file
--:bd remove current file from buffer
--:ls list files in buffer
---------------------------------------------------------
---------------------------------------------------------
First step: open and edit
To one newer, we only need to know little commands to use vi/vim. There are 2 modes when we start it.
-- command mode : it is default mode, and we can't input characters as other text editors. We can input commands in this mode.
-- insert mode: we can edit text.
To switch from [command mode] to [insert mode], press "i".
To return [commnad mode], press "Esc"
There are some other modes in some documents, don't care about them. The others can be classified into [command mode] in someway.
Now, there are some useful commands in the [command mode]
--"dd", delete current cursor line
--"yy", copy current cursor line
--"nx", n is a number(1, 2, ....), delete n characters from the cursor
--"p", paste. maybe to below line for one line, maybe to follow the current cursor for characters
--"h"/"j"/"k"/"l", h: move left, j: move down, k: move up, l: move right. in the lastest version, the direction arrows work also.
--":q!" quit vim without save
--":w"/":wq" save(/save and quit) file
--"/words" search word, words respresents the string
Now we can edit file thought without efficiently.
---------------------------------------------------------
Further step: tips
--ctags
installation: don't use the package "elvis-tools", use the "exuberant-ctags"
preparation: to create one tags file for vim
---ctags -R *
---:set tags=tagsfilepath
usage:
---ctrl+] goto the defination
---ctrl+o go back
--plugins
To install plugin, just put vim file into ~/.vim/plugin, and help text to ~/.vim/doc. Use :helptags ~/.vim/doc in vim to create helps.
Here is one alternate plugin, it is useful, it was written by Michael Sharpe
please refer to: http://www.vim.org/scripts/script.php?script_id=31
A few of quick commands to swtich between source files and header files quickly.
:A switches to the header file corresponding to the current file being edited (or vise versa)
:AS splits and switches
:AV vertical splits and switches
:AT new tab and switches
:AN cycles through matches
:IH switches to file under cursor
:IHS splits and switches
:IHV vertical splits and switches
:IHT new tab and switches
:IHN cycles through matches
--switch in files
--:e filename add new file into buffer
--:bn/bN switch to next/previous file
--:b(number) switch to nth file
--:bd remove current file from buffer
--:ls list files in buffer
---------------------------------------------------------
相关文章推荐
- vim tips
- Best of VIM Tips(译注) - 连载5 查找(d)
- Vim tips——Working with external commands
- VIM TIPS
- vim tips
- Best of Vim Tips
- vim tips: 执行外部命令
- VIM Tips
- vim配置过程中的几个TIPS
- VIM Tips
- Best of VIM Tips(译注) - 连载6 查找(e)
- Best of Vim Tips
- vim tips 集锦
- emacs tips vim
- 12 Vim Tips
- vim的各种tips
- VIM小Tips--持续update~
- 工欲善其事,必先利其器--vim-tips
- Vim indent tips
- Best of VIM Tips