Vim configuration of the primary road---to create their own vim

Source: Internet
Author: User
Tags set background sorted by name git clone






1, Vim is the ancient artifact of Linux programmer programming



Vim is the most famous text/code Editor on the Linux system, and it is also an enhanced version of the VI editor of the early years, known as the best classic ancient artifact in the text/code Editor. The reason why it is such a reputation, I think mainly for the following reasons: 1. It is ancient and mysterious, the learning curve is steep, difficult to control, but once learned to benefit. is now regarded as a master, geek dedicated editor. So although Vim is already an antique-grade software, there are countless new people who are struggling to learn to use it. 2. Lightweight, needless to say, when only a text file (such as script code, configuration file) Simple editing, the use of the tool is of course the lighter the better. Vim is also a powerful tool for reading text files. 3. Classic clever editing methods and powerful features. It all the way to use the keyboard operation, the user must remember a bunch of shortcut keys, key combinations and a variety of commands to get started, once the use of proficiency in editing efficiency far beyond the rest of the editor, and with a variety of plug-ins, syntax highlighting, code completion, color scheme and other extremely rich resources and flexible configuration;






2, vim into also plug-ins, lost also plug-ins



Some people say, Vim is "into also plug-ins, loser also plug-ins." Vim's flexible configuration and rich plugins greatly enhance its functionality, but it also greatly increases our difficulty in managing vim. First, before using VIM, it must be properly configured, and the configuration of vim is extremely cumbersome. So there are many articles on the internet, such as "Universal Configuration" and "strongest configuration", which can be consulted. However, some of these articles have many errors, even the content of repetition, conflict, and these articles are "to give people to fish, rather than grant people to fishing", the configuration they gave can be copied, but often make people unclear so. Vim is rich in plug-ins, there is no lack of the use of a variety of plug-ins to configure VIM as a powerful IDE, but Vim's plug-in management is very difficult, because each installation of a plug-in, it is necessary to put the plug-in files into the VIM installation path plugin, AutoLoad, Syntax, doc and other directories. Fortunately, Vundle turned out, it not only solves the problem of the Vim plug-in in the file system, while being able to automatically search and download plugins.






3. Two files on vim




1. Viminfo


In Vim, Vim is automatically recorded and saved in the ~/.viminfo file. This is to facilitate the next processing, such as: Vim when you open the file, the cursor will automatically appear in the last location. The original searched string, the newly opened file is automatically highlighted.
the ~/.viminfo file is automatically generated by the system .


2. VIMRC


The VIMRC file is a VIM environment settings file. The overall vim setting is in the/ETC/VIMRC file. Modifying the/ETC/VIMRC file is not recommended, and each user can set up vim in the user's root directory and create a new ~/.VIMRC. Vim has more configuration options,


: Set All


You can view all the configuration items.
Common configuration:


: set nu
: set nonu whether to display line numbers

: set wrap
: set nowrap whether to wrap

: set hlsearch
: set nohlsearch whether search is highlighted

: set autoindent
: set noautoindent whether to indent automatically

: set backup Whether to automatically back up modified files. The default is no. If set bakcup, the filename ~ backup file will be generated automatically when modified.

: set ruler shows the status bar in the lower right corner
: set showmode displays the status bar in the lower left corner, like --INSERT--

: set displays a value different from the system default,

: syntax on
: syntax off Program syntax switch

: set bg = dark
: set bg = light display color tone



4, install the plug-in management---vundle



Vundle on GitHub: Https://github.com/VundleVim/Vundle.vim



If the installation of this page is all, because it is English version of the Chinese as a patriotic I, is tearful to understand, this is what ghosts, dear readers ~, trouble everyone to find Baidu Pro mom, its Baidu translation or wide to drip ~






This is my own. vimrc file, although it's simple, but it's definitely available.



The first half is from the great God on GitHub.



The latter part is to learn and summarize



Have any command that doesn't understand the set behind



Eg:set Scrolloff can be used



: Help command name to see what the hell



In front of the "is the annotation function oh like C language//


"Close vim compatibility mode, close all vim extensions
set nocompatible
             
"Close file type
filetype off

"Add the path of vundle to the path of vim
set rtp + = ~ / .vim / bundle / Vundle.vim

"Perform vundle initialization
call vundle # begin ()

"Let vundle manage this plugin
Plugin ‘VundleVim / Vundle.vim’

Plugin ‘tpope / vim-fugitive’

"plugin from http://vim-scripts.org/vim/scripts.html
Plugin ‘L9’

"plugin‘ taglist.vim ’
Plugin ‘taglist.vim’

"plugin from‘ thenerdtree ’
Plugin ‘nerdtree’

"plugin‘ vim-airline-themes ’
Plugin ‘vim-airline / vim-airline-themes’

"plugin‘ Valloric / YouCompleteMe ’
Plugin ‘Valloric / YouCompleteMe’

"Git plugin not hosted on GitHub
Plugin ‘git: //git.wincent.com/command-t.git’

"git repos on your local machine (i.e. when working on your own plugin)
"Plugin‘ file: /// home / gmarik / path / to / plugin ’

"The sparkup vim script is in a subdirectory of this repo called vim.
"Pass the path to set the runtimepath properly.
Plugin ‘rstacruz / sparkup’, {‘rtp’: ‘vim /‘}

"Install L9 and avoid a Naming conflict if you ’ve already installed a
"different version somewhere else.
"Plugin‘ ascenator / L9 ’, {‘ name ’:‘ newL9 ’}

"All of your Plugins must be added before the following line
call vundle # end ()

"To ignore plugin indent changes, instead use:
filetype plugin indent on

"Brief help
": PluginList-lists configured plugins
": PluginInstall-installs plugins; append`! `To update or just
": PluginUpdate
": PluginSearch foo-searches for foo; append`! `To refresh local cache
": PluginClean-confirms removal of unused plugins; append`! `To auto-approve removal
"see: h vundle for more details or wiki for FAQ

"Record History Lines
set history = 1000
"Show ruler
set ruler
"Set line number
set number
"Show current operating mode
set showmode
"Always display the status line of the last window
set laststatus = 2
"Set the height of the command line
set cmdheight = 2
"Cursor moves to the top and bottom of the buffer for 3 lines
set scrolloff = 3
"Show blanks between divided windows for easy reading
set fillchars = vert: /, stl: /, stlnc: /
"Close error bell
set noerrorbells
"Turn off using visual ring instead of call
set novisualbell
"When vim is editing, if the command is wrong, a sound will be emitted, this setting removes the sound
set t_vb =
"Do not show tips for assisting Somali children at startup
set shortmess = atI
"Syntax highlighting
syntax on
"color molokai
"coloring scheme
colorscheme desert
"background
set background = dark
"Underline the cursor
set cursorline
"Turn on the highlighted cursor bar
set cursorcolumn
"Delete with spaces
set backspace = 2
"Allow backspace and cursor keys to cross line boundaries (not recommended)
set whichwrap + = <,>, h, l
"Replace tabs with spaces
set expandtab
set smarttab
"Set newline auto-indent to 4 spaces
set shiftwidth = 4
"Set tab to 4 spaces
set tabstop = 4
"
set softtabstop = 4
"Apply the alignment format of the current line to the next line
set autoindent
"Automatically indent inline code blocks when coding in C
set cindent
let g: rehash256 = 1
let g: molokai_original = 1
"set the colorcolumn
 highlight ColorColumn ctermbg = 237 guibg = gray30
 execute "set colorcolumn =". join (map (range (2,259), ‘" + ". v: val’), ‘,’)
"Files, backups and encoding
set nobackup
set noswapfile
set autoread
set autowrite
set autochdir
set fileencodings = utf-8
set fileformats = unix, dos, mac
filetype plugin on
filetype indent on
"
set showmatch
set matchtime = 2
set hlsearch
set incsearch
set ignorecase
set smartcase
set magic
set lazyredraw
set nowrapscan
set iskeyword + = _, $, @,%, #,-,.
if has ("gui_running")
    colorscheme solarized
endif
set guifont = DejaVu \ Sans \ Mono \ 15
set guioptions = aegic
"Configure taglist
"Make taglist appear to the left of vim
let Tlist_Use_Right_Window = 1
"When displaying tags of multiple files at the same time, only the current file is displayed, and other files are collapsed
let Tlist_File_Fold_Auto_Close = 1
"Show tags in only one file, default is to show multiple
let Tlist_Show_One_File = 1
"Tag's sorting rules, sorted by name. By default, they are sorted in the order they appear in the file.
let Tlist_Sort_Type = ‘name’
"When the Taglist window opens, it immediately switches to the focused state
let Tlist_GainFocus_On_ToggleOpen = 1
"If the taglist window is the last window, exit vim
let Tlist_Exit_OnlyWindow = 1
"Set the form width to 32, you can set it according to your preference
let Tlist_WinWidth = 32
"It's more important here, set the position of ctags
let Tlist_Ctags _ = ‘/ bin / ctags’
"Hot key settings, I set to ctrl + t to call out and close the Taglist
map <C-t>: TlistToggle <CR>
"Set the nerd tree to vim to open automatically
autocmd vimenter * NERDTree
"Nerdtree can be opened when there is no specific file
autocmd StdinReadPre * let s: std_in = 1
autocmd VimEnter * if argc () == 0 &&! exists ("s: std_in") | NERDTree | endif

"Set shortcut to open nerdtree: ctrl + n
map <C-n>: NERDTreeToggle <CR>

"Close vim with only one window open explorer
autocmd bufenter * if (winnr ("$") == 1 && exists ("b: NERDTree") && b: NERDTree.isTabTree ()) | q | endif

"Set different highlights for different files
function! NERDTreeHighlightFile (extension, fg, bg, guifg, guibg)
exec ‘autocmd filetype nerdtree highlight‘. a: extension. ’ctermbg =‘. a: bg. ’ctermfg =‘. a: fg. ’guibg =‘. a: guibg. ’guifg =‘. a: guifg
exec ‘autocmd filetype nerdtree syn match‘. a: extension. ’# ^ \ s \ +. *‘. a: extension. ‘$ #’
endfunction
call NERDTreeHighlightFile (‘jade’, ‘green’, ‘none’, ‘green’, ‘# 151515’)
call NERDTreeHighlightFile (‘ini’, ‘yellow’, ‘none’, ‘yellow’, ‘# 151515’)
call NERDTreeHighlightFile (‘md‘, ‘blue’, ‘none’, ‘# 3366FF’, ‘# 151515’)
call NERDTreeHighlightFile (‘yml’, ‘yellow’, ‘none’, ‘yellow’, ‘# 151515’)
call NERDTreeHighlightFile (‘config’, ‘yellow’, ‘none’, ‘yellow’, ‘# 151515’)
call NERDTreeHighlightFile (‘conf’, ‘yellow’, ‘none’, ‘yellow’, ‘# 151515’)
call NERDTreeHighlightFile (‘json’, ‘yellow’, ‘none’, ‘yellow’, ‘# 151515’)
call NERDTreeHighlightFile (‘html’, ‘yellow’, ‘none’, ‘yellow’, ‘# 151515’)
call NERDTreeHighlightFile (‘styl’, ‘cyan’, ‘none’, ‘cyan’, ‘# 151515’)
call NERDTreeHighlightFile (‘css’, ‘cyan’, ‘none’, ‘cyan’, ‘# 151515’)
call NERDTreeHighlightFile (‘coffee’, ‘Red’, ‘none’, ‘red’, `` #
151515 ‘)
call NERDTreeHighlightFile (‘js’, ‘Red’, ‘none’, ‘# ffa500’, ‘# 151515’)
call NERDTreeHighlightFile (‘php’, ‘Magenta’, ‘none’, ‘# ff00ff’, ‘# 151515’)
"Set these variables in vim
let g: NERDTreeDirArrowExpandable = ‘‘
let g: NERDTreeDirArrowCollapsible = ‘‘
let g: solarized_base16 = 1
"Setting the progress bar theme
let g: airline_theme = "luna"
"This is required after installing the font"
let g: airline_powerline_fonts = 1
"Turn on the tabline function for easy viewing of buffers and switching, this function is quite good"
"I also omitted the minibufexpl plugin, because I'm used to using multiple buffers under one tab."
let g: airline # extensions # tabline # enabled = 1
let g: airline # extensions # tabline # buffer_nr_show = 1
"
"Setting Toggle Buffer Shortcuts"
nnoremap <C-N>: bn <CR>
nnoremap <C-P>: bp <CR> "
"Closed status shows blank sign count, this is not very useful to me"
let g: airline # extensions # whitespace # enabled = 1
let g: airline # extensions # whitespace # symbol = ‘!’
"The latest status will not appear unless it is sub-contracted (within 1 minute), so set to 2 and will always appear
set laststatus = 2
"The default color of the terminal is 8 colors, now it is set to 256 colors.
set t_Co = 256
"airline, disabled by default, so you need to add the following statement
let g: airline # extensions # tabline # enabled = 1
"The splitter can determine the independent progress bar, here is where you define the‘ | ’key
let g: airline # extensions # tabline # left_sep = ‘‘
let g: airline # extensions # tabline # left_alt_sep = ‘|‘ 





5, install plug-ins encountered various problems



Question 1: English can not understand (Baidu translation)



Issue 2: Directory does not know where Ann (one is # under the user, one is $ under the user, generally installed to $ under. VIRMC)



Question 3: What to do without the. vimrc file (please follow me)


Cdvim. VIMRC


Issue 4: I am not able to install the path I gave (delete the wrong thing to think about it, be sure to install on GitHub, do not look at the blog, most except, to two commands directly installed, not to help you become the vim of the Great God)



Issue 5: But the installation of a plug-in will be used (: Plugininstall to install)



See done!, you can peace of mind ~ ~ ~



Question 6: Beginner, just like me, do not want to dress a divine vim, with flowers, can use, and not ugly, and so really feel the VIM programming command is familiar, in go to toss it ~ ~ ~



6, vim Everyone in the installed plug-in has



(1) TagList: File structure



(2) The Nerd Tree: Resource Manager



(3) Airline: status bar



(4) CTRLP: Find tool



。。。。。。。。。。 There are too many vim plugins.



Various downloads or git clone please go to GitHub Search, the highest ranking is definitely what you want ~ ~ ~



7, I am equipped with vim, not good do not spray, to send flowers



650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/82/3D/wKioL1dPDYnjOnmJAADDtMV2xKA438.png "title=" 2016-06-01 23-23-43 screen. png "alt=" Wkiol1dpdynjonmjaaddtmv2xka438.png "/>



This article from "Momo is spicy moe" blog, please be sure to keep this source http://momo462.blog.51cto.com/10138434/1785339



Vim configuration of the primary road---to create their own vim


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.