Transferred from: http://os.51cto.com/art/201507/484174.htm
Vim is a versatile, lightweight text editing tool on Linux. Although it is quite difficult for ordinary Linux users to start learning, it is worth learning because of the benefits. As for functional aspects, VIM can be fully customized via plugins. However, due to its advanced configuration, you may need to spend some time on its plug-in system to be able to personalize vim efficiently. Fortunately, we have several tools to simplify our use of vim plugins. Vundle is a tool that I use every day.
1. Vundle
Introduction
The full name of Vundle (Https://github.com/VundleVim/Vundle.vim) is the Vim Bundle, which is a vim plug-in management tool. Vundle allows you to install, update, search, and clean up vim plugins very easily. It can also manage your run-time environment and help with tagging. I will show you how to install and use Vundle in this tutorial.
2. Installing Vundle
First, if you don't have git on your Linux system, install it (http://ask.xmodulo.com/install-git-linux.html).
Next, create a directory where thevim plugin will be installed after it is downloaded . By default, the directory is located in ~/.vim/bundle.
Now install the Vundle as shown below. Please note:Vundle itself is another vim plugin . As a result, we installed the Vundle under the ~/.vim/bundle we created earlier.
3. Configure Vundle
Now set up your. vimrc file as follows:
SetNocompatible"this is necessary.FileType off"this is necessary. "you set the run-time path hereSetrtp+=~/.vim/bundle/Vundle.vim"Vundle InitializationCall Vundle#begin ()"this should always be the first onePlugin'Gmarik/vundle.vim' "This example comes from Https://github.com/gmarik/Vundle.vim READMEPlugin'tpope/vim-fugitive' "plugins from the http://vim-scripts.org/vim/scripts.htmlPlugin'L9' "git plugins that are not hosted on GitHubPlugin'Git://git.wincent.com/command-t.git' "git repositories on your local machine (i.e. when writing your own plugin)Plugin'File:///home/gmarik/path/to/plugin' "The sparkup vim script is under the Library subroutines directory of the software called Vim. "Pass the path and set the run-time path reasonably. Plugin'Rstacruz/sparkup', {'RTP':'vim/'} "avoid name collisions with L9Plugin'User/l9', {'name':'newL9'} "each plug-in should be preceded by this lineCall vundle#end ()"Required
You might want to explain the above configuration a little bit. by default, Vundle downloads and installs the Vim plugin from github.com or vim-scripts.org . You can modify the default behavior.
3.1. Plug-in installation method
- To install from http://vim-scripts.org/vim/scripts.html:
- To install from another git repository:
- To install from a local file:
3.2. Custom parameters
You can also customize other parameters, such as the run-time path of the plugin, which is useful if you are writing a plugin yourself, or if you want to load it from another directory that is not ~/.vim.
If you have a plugin of the same name, you can rename the plugin so that it does not conflict.
4.Vundle
Command Usage
Once you've set up the plugin with Vundle, you can use a few vundle commands to install, update, search, and clean unused plug-ins with Vundle.
4.1. Install a new plugin
The Plugininstall command installs all the plugins listed in your. vimrc file. You can also install only one specific plug-in, as long as you pass its name.
4.2. Clean unused plug-ins
If you have any unused plugins, just use the Pluginclean command to clean it up.
4.3. Search for plugins
The search function is useful if you want to install a plugin from the list of plug-ins provided.
During the search process, you can install, clean, study, or reload the same list on an interactive split screen. Installing the plugin does not automatically load your plugin. To automatically load the plugin, add the plugin to your. vimrc file.
This function is also often used, such as: Pluginsearch TagList, after the completion of the search, you can press ' I ' to install
5. Concluding remarks
Vim is a very good tool. Not only is it a great default text Editing tool, it can make your workflow faster and smoother, and can be converted into an IDE (integrated development environment) that supports almost any existing programming language. Vundle is great for quickly and easily personalizing a powerful vim environment.
Questions :
1. There has been a problem in the middle when call Vundle#begin () and call Vundle#end () are paired, always. VIMRC does not work, then switch to call VUNDLE#RC () and Filetpe plugin indent on both, Add the plugin to the middle.
2. Many plugins need to be set up. VIMRC, such as shortcut keys and paths, and so on, is a simple one. vimrc
"VIM ConfigurationSetmodelines=0"set a better deleteSetBackspace=2Syntax on"Syntax Highlighting"highlight current line with lightAutocmd Insertleave *se noculautocmd insertenter*se culSetSmartindent"Smart AlignmentSetAutoindent"Auto AlignSetConfirm"Pop-up confirmation box when working with unsaved or read-only filesSettabstop=4 "the width of the TAB keySetsofttabstop=4SetShiftwidth=4 "Unified Indentation is 4SetExpandtab"do not use spaces instead of tabsSetNumber"Show Line NumbersSethistory= - "number of historical recordsSetHlsearchSetIncsearch"search is highlighted, searching is gradually highlightedSetGdefault"in-line substitutionSetencoding=utf-8Setfileencodings=utf-8, ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936,utf- -, big5,euc-jp,latin1"Encoding SettingsColorScheme MolokaiSetGuifont=menlo:h16:cansi"Set FontSetLangmenu=zn_cn. utf-8SetHelplang=cn"Language SettingsSetRuler"In the edit process, the status line of the cursor position is displayed in the lower-right cornerSetlaststatus=1 "Always show status linesSetShowCmd"displays the currently executed command in the status line, and the unfinished instruction fragment is displayedSetscrolloff=3 "keep the distance of 3 lines when the cursor moves to the top and bottom of the bufferSetShowmatch"highlight the corresponding parenthesesSetMatchtime=5 "corresponding brace highlight time (in very one second)SetAutowrite"automatically save the current file when switching bufferSetWildmenu"command-line auto-complete operations in enhanced modeSetLinespace=2 "number of pixel lines inserted by word puttingSetwhichwrap=b,s,<,>,[,]"turn on the BACKSPACE key spacebar in normal or visual mode, LEFT arrow key in INSERT or Replace mode, skip function of right ARROW key.FileType plugin indent on"divided into three parts of the command: file On,file plugin on,file indent on are automatically recognized files type, with the file type script, using indentation definition fileSetFoldenable"Allow foldingSetCursorline"Highlight Current LineSetMagic"Set the Magic? God horse DongdongSetIgnoreCase"Search ignores caseFileType on"Open File type detection featureSetBackground=DarkSett_co= the "256 ColorsSetMouse=a"Allow MouseSetNocompatible"this is necessary.FileType off"this is necessary."Nerdtree------------------------------------------------------Let nerdtreequitonopen=1 "Nerdtree is quit, when file is openedLet nerdtreeshowbookmarks=1 "Display Bootmark"Let nerdtreechdirmode=2"Root is defaultDirectory"Let mapleader =","Map <F4>:nerdtreetoggle<cr>Map<C-F4>:nerdtreefind<cr>"Taglist------------------------------------------------------Let tlist_ctags_cmd='Ctags'Let tlist_show_one_file=1Let tlist_winwidth= -Let Tlist_exit_onlywindow=1Let Tlist_use_left_window=1"cscope------------------------------------------------------ifHas ("Cscope") Setcsprg=/usr/bin/CscopeSetcsto=0 SetCSTSetNocsverb"Add any database ifFilereadable ("Cscope.out") CS Add cscope. out "Else Add pointedElseIf $CSCOPE _db!=""CS Add $CSCOPE _db endifSetCsverbendif"ShortcutsNmap <[email Protected]>s:cs Find S <c-r>=expand ("<cword>") <CR><CR>Nmap<[email Protected]>g:cs Find G <c-r>=expand ("<cword>") <CR><CR>Nmap<[email Protected]>c:cs find C <c-r>=expand ("<cword>") <CR><CR>Nmap<[email Protected]>t:cs find T <c-r>=expand ("<cword>") <CR><CR>Nmap<[email Protected]>e:cs Find e <c-r>=expand ("<cword>") <CR><CR>Nmap<[email Protected]>f:cs find F <c-r>=expand ("<cword>") <CR><CR>Nmap<[email Protected]>i:cs Find I <c-r>=expand ("<cword>") <CR><CR>Nmap<[email Protected]>d:cs Find D <c-r>=expand ("<cword>") <CR><CR>"Vundle--------------------------------------------------------Setrtp+=~/.vim/bundle/Vundle.vim Call VUNDLE#RC () Plugin'Gmarik/vundle.vim'Plugin'Tpope/vim-surround'Plugin'Bling/vim-airline'Plugin'Scrooloose/nerdtree'Plugin'Taglist.vim'Plugin'Cscope.vim'filetype plugin indent on"Required
View Code
[Vundle] using vundle tools to manage vim plugins