The VIM editor is a powerful text editor. For a C + + beginner, you can use Vim to write your favorite code. But accustomed to using the IDE under Windows, the first experience of vim is really bad, unlike the programming habits of VS, and its inconvenient to write code is very inefficient. There are many online users have to share their vim configuration, the following is the blogger according to their own custom configuration of the Vim editor:
Operating system Environment: CentOS 6.7 (64-bit)
The VIM profiles for different operating systems are located in the same location, but Vim's configuration files are. VIMRC (files that begin with Linux '. ') are hidden files, and buckets can be displayed ls-l. Like my. vimrc file is under the/HOME/ETC path
。 650) this.width=650; "Src=" http://img.blog.csdn.net/20160526133300750?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/center "Align=" Middle "style=" font-size:14px; "/>
650) this.width=650; "Src=" http://img.blog.csdn.net/20160526133342952?watermark/2/text/ Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/center "Align=" Middle "/>
After finding the. VIMRC, we can add our favorite configurations.
Due to the low level of bloggers, the blogger's Vim is configured with some of the following simple features:
Show line Numbers
Syntax highlighting
Show Ruler
Displays the commands you have entered so that you can see them clearly.
Displays Chinese help.
Code completion.
Auto Indent.
Encoding settings
Highlight the matching parentheses.
Show status line
Map Ctrl + A to automatically select all and copy the shortcut keys, convenient to copy the code out.
Set F2 to quickly clear empty lines in the code.
The code for these configurations is as follows, you can directly copy into your own. vimrc file, re-open vim to see the effect.
<span style= "FONT-SIZE:18PX;" > "Show line number set NU" syntax highlighting syntax on</span>
<span style= "FONT-SIZE:18PX;" > " Highlight current line with light autocmd insertleave * se nocul autocmd insertenter * se cul The status line displays the content set statusline=%f%m%r%h%w\ [format=%{&ff}]\ [type=%y]\ [pos=%l,%v][%p%%]\ %{strftime (\ "%d/%m/%y\ -\ %H :%m\ ")}" show ruler set ruler " input commands are displayed, Look clearly set showcmd " Show Chinese help if version >= 603 set helplang=cn set encoding= Utf-8endif "code completion set completeopt=preview,menu " Auto indent set autoindentset cindent " Encoding settings set enc=utf-8set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 "Language Settings Set langmenu=zh _cn. UTF-8SET&NBSP;HELPLANG=CN " Highlight matching brackets set showmatch" match parentheses highlight time (in seconds) Set matChtime=1 "Show status line Set laststatus=1" Map Ctrl + A to select all and copy the shortcut keys, convenient to copy the code out map <c-a> ggvgymap! < C-a> <esc>ggvgymap <f12> gg=g "Press F2 to quickly eliminate blank lines in your code nnoremap <f2> :g/^\ S*$/d<cr></span>
650) this.width=650; "src=" http://img.blog.csdn.net/20160527142421719 "/>
Where, "begins with a comment. Of course, if you need to add any new features to the. VIMRC in the future.
Solves some of the operational convenience of vim, we also need some plug-ins to help us write code, that is ctags and TagList plug-ins. With this plugin, we will not say that we are not accustomed to the environment under Linux, it should be similar to the IDE under the VS.
(a) Ctag plug-in
Tags file is an index file produced by the Ctags program, the Ctags program is called "Exuberant Ctags", is a UNIX alternative to the Ctags program, and more powerful than it is the default Ctags program on most Linux distributions. What is a tags file for? If you read a function call when reading a program, or a variable, or a macro, and so on, you want to know where their definition is, just use the cursor on a function or variable, press CTRL +], the cursor will automatically jump to its definition, very powerful.
First we download Ctags plugin, we download http://vdisk.weibo.com/s/aQWqsQYz_IDve?from=page_100505_profile&wvr=6 here in this download relatively fast.
Here is an example of version 5.8.
<span style= "FONT-SIZE:18PX;" > Unzip the installation with the following command: $ tar-xzvf ctags-5.8.tar.gz$ cd ctags-5.8$./configure</span><pre name= "code" class= "CPP" > $ make
<span style= "FONT-SIZE:18PX;" ># make install//requires root access </span>
650) this.width=650; "src=" http://img.blog.csdn.net/20160527142933237 "align=" Middle "/>
This will unzip and install it. We can make sure the installation is done by Whereis Ctags.
<span style= "FONT-SIZE:14PX;" > After the successful installation, to generate tags files for the source files, you can enjoy the ctags for reading code to bring convenience. </span><span style= "FONT-SIZE:18PX;" >$ Ctags-r recursive for the current directory and all the code files under the subdirectory generated tags file for some source generated tags files, using the following command $ ctags filename.c filename1.c file.h or ctags *.c *.h< /SPAN>
(ii) Installation of TagList
TagList is a vim plugin used to browse the source code. It can display files and functions of the current project
First download the TagList in http://http://www.vim.org/scripts/script.php?script_id=273.
Unzip Taglist_xx.zip under the ~/.vim directory
<span style= "FONT-SIZE:18PX;" >unzip taglist_xx.zip</span>
Add the following two sentences to your ~/.VIMRC file:
<span style= "FONT-SIZE:18PX;" >let Tlist_show_one_file=1let tlist_exit_onlywindow=1</span>
A quicker way is to enter the following commands directly:
wget Http://www.vim.org/scripts/download_script.php?src_id=19574-O abc.zip && unzip-o-D./Abc.zip && MV doc/taglist.txt/usrimim[0-9][0-9]/doc/&& MV plugin/taglist.vim/usrimim[0-9][0-9]/plugin/&& RmDir Doc Plugin
Then vim opens the file, and the underlying command line enters Tlist. Direct!!!
This article is from the "Straw Sunshine" blog, please be sure to keep this source http://helloleex.blog.51cto.com/10728491/1785014
Vim editor for fast configuration under Linux