"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Basic configuration settings
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
filetype on "detect file type
filetype indent on "Use different indentation formats for different file types
filetype plugin on "Allow plugin
filetype plugin indent on "Start automatic completion
set nu
"set relativenumber number" relative line number, use Ctrl + n to switch between relative / absolute line number
set history = 2000 "history storage length
set nocompatible "non-compatible vi mode, to avoid some bugs and limitations of previous versions
set autoread "Automatically load after file modification
set shortmess = atI "Do not show the prompt to assist Somali children when starting
set t_ti = t_te = "After exiting vim, the content is displayed on the terminal screen
set title "change the terminal ‘s title
set novisualbell "do n‘t beep
set noerrorbells "do n‘t beep
set t_vb =
set tm = 500
set mat = 2 "Blink times every second when matching brackets
set showmatch "Bracket matching situation
set hidden "A buffer becomes hidden when it is abandoned
set wildmode = list: longest
set ttyfast
set wildignore = *. swp, *., *. pyc, *. class
set scrolloff = 7 "At least 7 lines above and below the line where the cursor is
"set mouse = a" Enable the mouse for all modes
set selection = old
set selectmode = mouse, key
set viminfo ^ =% "Remember info about open buffers on close
set magic "regular expression matching form
set backspace = eol, start, indent "Configure backspace so it acts as it should act
set whichwrap + = <,>, h, l
" search for
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
set hlsearch "Highlight the text hit by the search.
set ignorecase "Ignore case when searching
set incsearch "Search as you type
set smartcase "When there is one or more capital letters, it is still case sensitive
"Collapse
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"set foldenable
"set foldmethod = indent
"set foldlevel = 99
"Indent
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
set smartindent "Smart indent
set autoindent "Always automatically indent
set tabstop = 4 "Set the width of the Tab key (the number of equivalent spaces)
set shiftwidth = 4 "Number of spaces automatically aligned
set softtabstop = 4 "When pressing the backspace key, you can delete 4 spaces at a time
set smarttab "insert tabs on the start of a line according to shiftwidth, not tabstop
set expandtab "Automatically convert Tab into spaces (use Ctrl + V + Tab when you need to enter the real Tab key)
set shiftround "Use multiple of shiftwidth when indenting with‘ <‘and‘> ‘
"Coding
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
set encoding = utf-8
set fileencodings = ucs-bom, utf-8, cp936, gb18030, chinese, big5, euc-jp, euc-kr, latin1
set fileencoding = utf-8
set helplang = cn
set termencoding = utf-8 "This sentence only affects Vim in normal mode (non-graphical interface)
set ffs = unix, dos, mac "Use Unix as the standard file type
set formatoptions + = m "In the case of text with a Unicode value greater than 255, there is no need to wait for spaces before wrapping.
set formatoptions + = B "When merging two lines of Chinese, do not add spaces in the middle:
"Grammar
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
syntax enable "Turn on syntax highlighting
syntax on
"Withdraw
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"set undolevels = 1000" How many undos
"set undoreload = 10000" number of lines to save for undo
"if v: version> = 730
"set undofile" keep a persistent backup file
"set undodir = ~ / bak / vimundo /
"endif
" Status Bar
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
set ruler "Display the current line number and column number
set showcmd "Show the command being entered in the status bar
set showmode
set statusline =% <% f \% h% m% r% =% k [% {(& fenc == \ "\")? & enc: & fenc}% {(& bomb? \ ", BOM \": \ "\ ")}] \% -14. (% L,% c% V%) \% P
set laststatus = 2 "The height of the command line (under the status line), the default is 1, here is 2
"Relative absolute line number
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"autocmd FocusLost *: set norelativenumber number
"autocmd FocusGained *: set relativenumber
"autocmd InsertEnter *: set norelativenumber number
"autocmd InsertLeave *: set relativenumber
"set cursorline" highlights the current line, use Ctrl + m to switch whether to display
"set cursorcolumn" highlights the current column, you can use Ctrl + m to switch whether to display
"set backup"
"Automatically save when exiting insert mode
"autocmd InsertLeave *: w! <ESC>
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Custom shortcut keys
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Leading Symbol
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
let mapleader = ‘,’
let g: mapleader = ‘,’
"Commonly used shortcut keys
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"To the end of the line
noremap H ^
noremap L $
"Paste format
noremap <leader> p: set paste <CR> i
noremap <leader> n: set nopaste <CR>
"Go to the first non-blank character in the line where the cursor is
"map 0 ^
"Copy from cursor to end of line, excluding end-of-line character
map Y y $
"t / T increase blank line
nmap t o <ESC>
nmap T O <ESC>
"Resume Undo
nnoremap U <C-r>
"Save
map <leader> w: w! <cr>
"Save and exit the current window
map <leader> q: q <CR>
"Save and suspend
map <leader> z: wa! <cr> <C-z>
" select all
map <C-a> ggVG
"Relative / absolute line number conversion
noremap <C-n>: call NumberToggle () <cr>
cnoremap <C-n>: call NumberToggle () <cr>:
"Highlight the current row / column switch
"map <C-m>: call CusorCulLineToggle () <cr>
"Open / close all folds
map <leader> o zR
map <leader> c zM
"Press jf continuously to exit insert / command line / visual mode
inoremap jk <ESC> l
cnoremap jk <ESC> l
vnoremap jf <ESC> l
"Ctrl + c copy when selected
vmap <C-c> "+ y
"Press; enter the command line mode directly
"nnoremap;:
"Move the cursor line up or down
"nmap <S-k>: m-2 <cr>
"nmap <S-j>: m + 1 <cr>
"vmap <S-k>: m-2 <cr>
"vmap <S-j>: m + 1 <cr>
"Search Find Shortcut Key
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Replace, match pattern using very magic
map \:% s / \ v
"Find, match pattern using very magic
nnoremap / / \ v
vnoremap / / \ v
"Remove the highlight after searching
noremap <silent> <leader> /: nohls <CR>
"The searched content is always displayed in the center of the screen
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
nnoremap <silent> * * zz
nnoremap <silent> # #zz
nnoremap <silent> g * g * zz
"Shortcut keys in Normal Mode
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Quick edit revimrc
nmap <silent> <leader> ev: e $ MYVIMRC <CR>
nmap <silent> <leader> sv: so $ MYVIMRC <CR>
"Quick scroll
nnoremap <C-e> 2 <C-e>
nnoremap <C-y> 2 <C-y>
"Shortcut keys in Command Line Mode
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
cnoremap <C-j> <t_kd>
cnoremap <C-k> <t_ku>
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
"Function key
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"F6 syntax highlight shortcut keys
nnoremap <F6>: exec exists (‘syntax_on‘)? ‘syn off‘: ‘syn on‘ <CR>
"F7 Tab Navigation
"nnoremap <silent> <F7>: TlistToggle <CR>
nnoremap <leader> m: TlistToggle <CR>
"F8 tab navigation
"nmap <F8>: TagbarToggle <CR>
"Multi-window tab shortcuts
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Switch between multiple windows
map <C-j> <C-W> j
map <C-k> <C-W> k
map <C-h> <C-W> h
map <C-l> <C-W> l
"Disbale paste mode when leaving insert mode
map <leader> tn: tabnew <cr>
map <leader> to: tabonly <cr>
map <leader> tc: tabclose <cr>
map <leader> tm: tabmove <cr>
"Opens a new tab with the current buffer ‘s path
"Super useful when editing files in the same directory
map <leader> te: tabedit <C-r> = expand ("%: p: h") <cr> /
"Miscellaneous
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Disbale paste mode when leaving insert mode
set paste
"autocmd InsertLeave * set nopaste
"w !! to sudo & write a file
cmap w !! w! sudo tee> / dev / null%
"Swap implementations of` and ‘jump to markers
"By default,‘ jumps to the marked line, `jumps to the marked line and
"column, so swap them
nnoremap ‘`
nnoremap `‘
"Automatically reload vimrc when it ‘s saved
autocmd BufWritePost .vimrc so ~ / .vimrc
"; can repeat fx / tx. so do not map it
nnoremap <leader> v V`}
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Theme color display
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Set extra options when running in GUI mode
if has ("gui_running")
set guifont = Monaco: h14
set guioptions- = T
set guioptions + = e
set guioptions- = r
set guioptions- = L
set guitablabel =% M \% t
set showtabline = 1
set linespace = 2
set noimd
set t_Co = 256
endif
"Modify theme and color display
"colorscheme solarized
set background = dark
set t_Co = 256
"colorscheme molokai
colorscheme desert
"Set the background color of a column to be the same as the color of a row of numbers
hi! link SignColumn LineNr
hi! link ShowMarksHLl DiffAdd
hi! link ShowMarksHLu DiffChange
"To prevent mistakes in the entire line marked red to cause unclear
highlight clear SpellBad
highlight SpellBad term = standout ctermfg = 1 term = underline cterm = underline
highlight clear SpellCap
highlight SpellCap term = underline cterm = underline
highlight clear SpellRare
highlight SpellRare term = underline cterm = underline
highlight clear SpellLocal
highlight SpellLocal term = underline cterm = underline
"settings for kien / rainbow_parentheses.vim
"autocmd VimEnter * RainbowParenthesesToggle
"autocmd Syntax * RainbowParenthesesLoadRound
"autocmd Syntax * RainbowParenthesesLoadSquare
"autocmd Syntax * RainbowParenthesesLoadBraces
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Miscellaneous configuration
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
autocmd! bufwritepost _vimrc source% "The vimrc file is automatically loaded after modification. Windows.
autocmd! bufwritepost .vimrc source% "The vimrc file is automatically loaded after modification. Linux.
"set completeopt = longest, menu" Auto-complete configuration, make Vim's completion menu behave the same as general IDE (see VimTip1228)
"Close the preview window automatically after leaving insert mode
"autocmd InsertLeave * if pumvisible () == 0 | pclose | endif
"Enter to select the current item
inoremap <expr> <CR> pumvisible ()? "\ <C-y>": "\ <CR>"
"Command line auto completion in enhanced mode
set wildmenu
"Ignore compiled files
"set wildignore = *. o, * ~, *. pyc, *. class
"General settings for Python files, such as no tabs, etc.
autocmd FileType python set tabstop = 4 shiftwidth = 4 expandtab ai
"If it does not work, determine if .viminfo is writable
if has ("autocmd")
au BufReadPost * if line ("‘ \ "")> 1 && line ("‘ \ "") <= line ("$") | exe "normal! g‘ \ "" | endif
endif
"Remove extra spaces
func! DeleteTrailingWS ()
exe "normal mz"
% s / \ s \ + $ // ge
exe "normal` z "
endfunc
autocmd BufWrite * .py: call DeleteTrailingWS ()
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Plugin management configuration starts
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Open the directory tree
nnoremap <silent> <F2>: NERDTreeToggle <CR>
"Tab Navigation
nnoremap <silent> <F10>: TlistToggle <CR>
let Tlist_Ctags_Cmd = ‘/ usr / bin / ctags’
"let Tlist_Show_One_File = 1" only show the tags of the current file
let Tlist_Exit_OnlyWindow = 1 "Quit Vim if the Taglist window is the last window
let Tlist_Use_Right_Window = 1 "displayed in the right window
let Tlist_File_Fold_Auto_Close = 1 "automatic folding
let Tlist_Sort_Type = "name" "items in tags sorted by name
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Plugin management configuration ends
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Custom functions
"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Relative absolute line number conversion
function! NumberToggle ()
if (& relativenumber == 1)
set norelativenumber number
else
set relativenumber
endif
endfunc
"Highlight the current row and column conversion
function! CusorCulLineToggle ()
if (& cursorcolumn == 1)
set nocursorcolumn
set nocursorline
else
set cursorcolumn
set cursorlineendif
endfunc
function! GoToFileEnd ()
normal G
endfunc
"" Define the function SetTitle, automatically insert the file header
autocmd BufNewFile * .py, *. cpp, *. c, *. sh, *. java exec ": call SetTitle ()"
function! SetTitle ()
"If the file type is a .sh file
if & filetype == ‘sh’
call setline (1, "\ #! / bin / bash")
call append (line ("."), "\ ##################################### ####### ")
call append (line (".") + 1, "\ # Copyright (c) 2015 Tencent, all rights reserved")
call append (line (".") + 2, "\ # File:" .expand ("%"))
call append (line (".") + 3, "\ # Author: lucasysfeng")
call append (line (".") + 4, "\ # Revision:" .strftime ("% Y-% m-%-d% H:% M:% S"))
call append (line (".") + 5, "\ # Description:")
call append (line (".") + 6, "\ ################################### ######### ")
elseif & filetype == ‘h’
call setline (1, "/ ******************************************* ********* ")
call append (line ("."), "\ # Copyright (c) 2015 Tencent, all rights reserved")
call append (line (".") + 1, "\ # File:" .expand ("%"))
call append (line (".") + 2, "\ # Author: lucasysfeng")
call append (line (".") + 3, "\ # Revision:" .strftime ("% Y-% m-%-d% H:% M:% S"))
call append (line (".") + 4, "\ # Description:")
call append (line (".") + 5, "************************************* *************** / ")
call append (line (".") + 6, "#pragma once")
call append (line (".") + 7, "")
elseif & filetype == ‘cpp‘ || & filetype == ‘c‘
call setline (1, "/ ******************************************* ********* ")
call append (line ("."), "\ # Copyright (c) 2015 Tencent, all rights reserved")
call append (line (".") + 1, "\ # File:" .expand ("%"))
call append (line (".") + 2, "\ # Author: lucasysfeng")
call append (line (".") + 3, "\ # Revision:" .strftime ("% Y-% m-%-d% H:% M:% S"))
call append (line (".") + 4, "\ # Description:")
call append (line (".") + 5, "************************************* *************** / ")
call append (line (".") + 6, "#include <stdio.h>")
call append (line (".") + 7, "#include <iostream>")
call append (line (".") + 8, "#include <string>")
call append (line (".") + 9, "")
call append (line (".") + 10, "using namespace std;")
call append (line (".") + 11, "")
call append (line (".") + 12, "int main ()")
call append (line (".") + 13, "{")
call append (line (".") + 14, "")
call append (line (".") + 15, "return 0;")
call append (line (".") + 16, "}")
elseif & filetype == ‘python’
call setline (1, "\ #! / usr / bin / env python")
call append (line ("."), "\ #-*-coding: utf-8-*-")
call append (line (".") + 1, "\ ################################### ######### ")
call append (line (".") + 2, "\ # Copyright (c) 2015 Tencent, all rights reserved")
call append (line (".") + 3, "\ # File:" .expand ("%"))
call append (line (".") + 4, "\ # Author: lucasysfeng")
call append (line (".") + 5, "\ # Revision:" .strftime ("% Y-% m-%-d% H:% M:% S"))
call append (line (".") + 6, "\ # Description:")
call append (line (".") + 7, "\ ################################### ######### ")
endif
"After creating a new file, automatically locate to the end of the file
"autocmd BufNewFile * exec": call GoToFileEnd () "
call GoToFileEnd ()
endfunc
vim configuration (current version) 2015.10.4