Linux-vim use
At present, the work environment is basically transferred to the Linux platform (ubuntu-16.04 x64), but it is inconvenient to view the code under the Linux platform. In fact, is accustomed to sourceinsight, and do not want to through the way of wine installation sourceinsight. Think of the powerful tool of VIM! This also takes the environment mark down as a record of its own configuration.
- VIM Installation
- Add Ctags Plugin
- Add Tlist Plugin
- Add Winmanager Plugin
- My IVM.
- Summarize
VIM Installation
Installing Vim under Ubuntu is easy, with the Apt-get command you can complete the VIM installation
via Terminal input command:
sudo
Verify that the installation is successful. Enter VIM at the terminal to see if the VIM program is running correctly?
I can see that the VIM program has been opened in my terminal.
But every time you have to input vim to run the VIM program, as a lazy person I can not tolerate this situation.
via terminal Input command (update-alternatives tool can easily open Vim program via input VI)
sudo300
When you start vim, a configuration file of two places is read.
The/ETC/VIM/VIMRC configuration file is global, regardless of which user starts Vim and reads the profile.
The ~/.VIMRC file is a profile for a user. Each user has a configuration file. But look carefully found that after the installation of Vim is not automatically generated ~/.VIMRC file. Then we'll create a new one ourselves, and we'll build up the relevant files as well.
In the terminal input command:
touch ~/.vimrcmkdir ~/.vim/{doc,plugin,syntax}
Is the new user's profile (~/.VIMRC), Manual (DOC), plug-in (plugin), do not know what folder (syntax)
The next step is how to install the plugin and configure the plugin
Add Ctags Plugin
Ctags is a tool for generating tags
In the terminal input
sudo apt-get install exuberant-ctags
Check if Ctags is installed correctly
How to use Ctags?
First go to the root of our project and enter the following command:
-R
The-r parameter represents a loop into each directory and generates a tags file. A tags file is generated under the root directory.
Tags saved is the item's so tag
Open the/fs/exec.c file in the root directory. Vim automatically reads the tags file under the current file.
The cursor moves to the tab that needs to jump click "
"Ctags设置 "设置ctags程序位置let‘/usr/bin/ctags‘"ctags自动查找tags文件set tags=tags;
This will only open the code file under the Directory folder vim would recursively go to the upper directory to find the tags file
Add Tlist Plugin
The Tlist plugin provides a preview of the variables and functions.
Enter https://sourceforge.net/projects/vim-taglist/files/vim-taglist/to download the ZIP archive package.
And unzip, unzip to get two folders (Doc,plugin)
Taglist.vim Copy to ~/.vim/plugin
Taglist.txt Copy to ~/.vim/doc
Back to the VIM software and enter tlist, you can see the tlist appear on the left/right
In fact, every time you start vim will need to manually start tlist, each time you exit vim and manually quit once tlist to completely exit vim. This is unscientific!
Edit the ~/.VIMRC file once again.
"设置Tlist"启动vim Tlist自动打开窗口"let Tlist_Auto_Open=1"只显示当前文件的Tlist,打开新文件后旧的Tlist会折叠"let Tlist_File_Fold_Auto_Close=1"当打开新的文件的时候会把旧的Tlist窗口关掉let Tlist_Show_One_File=1"如果Tlist是最后一个窗口退出vim"如果不设置当退出vim的时候还会停留在Tlist窗口"并且需要再次输入:q才能退出vimlet Tlist_Exit_OnlyWindow=1"Tlist显示在右侧let Tlist_Use_Right_Window=1
This does not open the Tlist_auto_open switch because we will use Winmanager to open the tlist in the back.
Add Winmanager Plugin
The Wimmanager plugin allows our VI to generate a window to preview the files in the directory
Enter http://www.vim.org/scripts/script.php?script_id=95 to download the ZIP archive package.
Of course, after the decompression is copied to the corresponding directory
Edit the ~/.VIMRC file. The function of each parameter is resolved clearly in the annotation
"Winmanager设置"Winmanager自动打开"会自动把Tlist也显示,所以把上面的Tlist_Auto_Open注释掉了let g:AutoOpenWinManager=1"设置布局,左上显示TagList,左下显示Wimmanagerg:"TagList|FileExplorer,BufExplorer""设置winManager的宽度,默认是25let g:winManagerWidth = 40"定义打开关闭winmanager快捷键为F8nmap <silent> <F8:WMToggle<cr>
After adding Tlist,winmanager to vim, we found that there were two problems.
The 1,tlist,winmanager is displayed on the left. And when entering VIN, the cursor is on the leftmost window. Not in the Vim input window. We need to get tlist,winmanager to the right.
2, when you exit Vim, you also need to Tlist,winmanager where it remains.
These two issues modify the plugin code can be done specifically see the code posted below
WINBUFNR (2) modified to WINBUFNR (3)
Add the following code at the end of the ~/.vim/plugin/winmanager.vim
"设置自动打开WinManager if g:AutoOpenWinManager autocmd VimEnter * nested call s:StartWindowsManager()|1wincmd w endif
Finally, I put all the ~/.VIMRC files I've configured.
"Set highlighting keyword displaySyntax enablethe display line numberSet numberthe set Help languageSet HELPLANG=CNthe Ctags settings"Set Ctags program locationLet Tlist_ctags_cmd = '/usr/bin/ctags '"ctags automatically find tags filesSet tags=tags;the set tlist"Start Vim tlist Auto Open window"Let Tlist_auto_open=1"Displays only the current file's tlist, and the old tlist will collapse when the new file is opened ."Let Tlist_file_fold_auto_close=1"When you open a new file, you turn off the old tlist window .Let tlist_show_one_file=1"If tlist is the last window to exit Vim"If you do not set it will remain in the Tlist window when you exit vim."and need to enter again: Q to exit VimLet tlist_exit_onlywindow=1"Tlist appears on the rightLet tlist_use_right_window=1 the Winmanager settings"Start vim Winmanager automatically open"will automatically show the tlist, so the above Tlist_auto_open commented outLet g:autoopenwinmanager=1"Set the layout, show TagList on the left, show Wimmanager on the left, and right display vimLet G:winmanagerwindowlayout ="taglist| Fileexplorer,bufexplorer ""Set the width of the Winmanager, default isLet G:winmanagerwidth = +"Define open close Winmanager shortcut key to F8Nmap <silent> <F8>:wmtoggle<cr>
My vim
I'm using vim now. Of course I like the simple main
Summarize
What is VIM? It's just a text editing tool. is a tool that you like to customize. Of course you can add a lot of things you like.
I hope you can use a vim! you like.
Linux-vim use