"*************************************** ****
"Global conditions
"*************************************** ****
"Set Operating System
If has ("Win32") | has ("win64") | has ("win32unix ")
Let G: iswin = 1
Let $ vimfiles = $ Vim. '/vimfiles'
Else
Let G: iswin = 0
Let $ vimfiles = $ home. '/. Vim'
Endif
"*************************************** ****
"Regular
"*************************************** ****
"File encoding
"Set encoding = UTF-8
Set fileencodings = ucs-bom, UTF-8, GBK
Set fileencoding = UTF-8
"File type identification, add related plug-ins and indentation scripts
"Filetype on
"Filetype plugin on
Filetype plugin indent on
"Set File Format
Set fileformat = Unix
Set fileformats = Unix
"Set Shell
If G: iswin = 0
Set shell = bash
Endif
"Session settings
Set sessionoptions + = slash, Unix
"Disable compatibility mode
Set nocompatible
"Read automatically when external Modification
Set autoread
"Set mouse
Set mouse =
"Setting history
Set history = 200
"Syntax highlighting
Syntax enable
"Highlight search results
Set hlsearch
"The row exceeding the length of the current row is rewound
Set wrap
"Row number settings
Set nu
"Smart indent: ts tabstop converts the tab key to space for display. It is mainly used for screen display and printing,
"If all tabs are used on the page, the page width is different in tabstop = 4 and tabstop = 8.
"STS softtabstop converts the number of tabs to spaces during editing. It must be used with expandtab.
"Et expandtab is inserted in the insert mode with a proper number of spaces.
"SW shiftwidth auto indent the number of white spaces used for each step
Set AI Ts = 4 STS = 4 et Sw = 4
"Set the color scheme
If has ("gui_running ")
Colorscheme desertex
Else
Colorscheme desert
Endif
"Changing Vim scan label rules
"The default completion sequence of VIM is"., W, B, U, T, I ", which means scanning:
"1. Current Buffer.
"2. Other window buffer window ??
"3. Other loaded buffer B...
Set CPT =., W, B
"Autowrite
Set Aw
"Case Insensitive during search
Set ignorecase
"Set IC
"Enhanced command line completion, type: H and press <tab> to look what happens
Set wildmenu
"Allows you to switch the cache if it is not saved.
Set hid
"Number of rows changed after reporting behavior
Set Report = 0
"The minimum number of rows displayed when the cursor moves
Set scroloff = 10
"Set the bell and pop-up Screen
Set novisualbell t_vb =
"Set Error Response
Set noerrorbells
"Load System-specific scripts
"Source $ vimruntime/vimrc_example.vim
If G: iswin = 1
Source $ vimruntime/mswin. Vim
Behave mswin
Endif
"Use CTRL-Q to do what CTRL-V used to do
Noremap <C-Q> <C-V>
Set ambiwidth = double
Set smarttab
Set backspace = 2
Set textwidth = 0
"Solved the problem that tab cannot be used in completion mode.
Map! <C-tab> <tab>
"Disable backup
Set nobackup
"Sets the encoding of the opened file.
"Sets the encoding guess list when the file is opened.
"Set fencs = UTF-8, gb18030, UTF-16, big5
"Set a help language later than 603
If version> = 603
Set helplang = Cn
Endif
"Undo history available persistent undo after restart
Set undofile
Set undodir = $ vimfiles/\ _ undodir
Set undolevels = 100 "Maximum number of changes that can be undone
"Ctrl-C Replication
Vmap <C-C> "+ Y
Imap <C-C> "+ Y
Map <C-C> "+ Y
Vmap <c-Insert> "+ Y
"Ctrl-V Paste
"CTRL-X and shift-del are cut
Vnoremap <C-X> "+ x
Vnoremap <s-del> "+ x
"CTRL-C and Ctrl-insert are copy
Vnoremap <C-C> "+ Y
Vnoremap <c-Insert> "+ Y
"CTRL-V and shift-insert are Paste
Map <C-V> "+ GP
Map <s-Insert> "+ GP
Cmap <C-V> <C-R> +
Cmap <s-Insert> <C-R> +
"Pasting blockwise and linewise selections is not possible in insert and
"Visual mode without the + virtualedit feature. They are pasted as if they
"Were characterwise instead.
"Uses the paste. Vim autoload script.
EXE 'inoremap <SCRIPT> <C-V> 'paste # paste_cmd ['I']
EXE 'vnoremap <SCRIPT> <C-V> 'paste # paste_cmd ['V']
"NMAP <c-V>" + GP
"Vmap <c-V> D" + GP <CR>
"Imap <c-V> <ESC>" + GP
"Map <c-V>" + GP
"Map <C-V>" + GP
"Map <s-Insert>" + GP
"Cmap <C-V> <C-R> +
"Cmap <s-Insert> <C-R> +
"EXE 'inoremap <SCRIPT> <C-V> 'paste # paste_cmd ['I']
"EXE 'vnoremap <SCRIPT> <C-V> 'paste # paste_cmd ['V']
"Imap <s-Insert> <C-V>
"Vmap <s-Insert> <C-V>
"Select all content shortcuts
Map <c-A> gg0vg $ <CR>
"Set tags
Set tags + =./tags
"Set to cancel swapfile
Set noswapfile
"*******************************
"Set tlist
"*******************************
Let tlist_ctags_cmd = 'ctags '"because we put it in environment variables, you can directly execute
Let tlist_process_file_always = 0 "whether to process tags.1: processing; 0: Not processing. Instead of updating tags in real time, it is unnecessary.
Let tlist_show_one_file = 1
"If the taglist window is the last window, exit Vim
Let tlist_exit_onlywindow = 1
Let tlist_show_menu = 1
Let tlist_winheight = 25
Let tlist_use_right_window = 1
Let tlist_file_fold_auto_close = 1
"Tasklist
"Map T: tasklist <CR>
NMAP <silent> <F4>: tlisttoggle <CR>
"*******************************
"Set winmanager
"*******************************
"Winmanager
"Let G: winmanagerwindowlayout = 'nerdtree | taglist'
"Let G: winmanagerwindowlayout = 'nerdtree'
"" Set the winmanager width. The default value is 25.
"Let G: winmanagerwidth = 30
"NMAP <F8>: wmtoggle <CR>
"Let G: autoopenwinmanager = 1
"*******************************
"Set minibufexplorer
"*******************************
"Let G: minibufexplmapwindownavvim = 1
"Let G: minibufexplmapwindownavarrows = 1
"Let G: minibufexplmapctabswitchbufs = 1
"Let G: minibufexplmodseltarget = 1
"Map! <C-tab>: BN <CR>
Map! <C-S-tab>: BP <CR>
"Minibuf always show
"Let G: minibufpolicermorethanone = 0
"*****************************
"Bufexplorer
"*****************************
"Let G: bufexplorerdefaulthelp = 0" do not show default help.
"Let G: bufexplorershowrelativepath = 1" show relative paths.
"Let G: bufpolicersortby = 'mru'" sort by most recently used.
"Let G: bufexplorersplitright = 0" Split left.
"Let G: bufpolicersplitvertical = 1" split vertically.
"Let G: bufexplorersplitvertsize = 30" split width
"Let G: bufpolicerusecuritywindow = 1" open in new window.
"Autocmd bufwinenter \ [Buf \ list \] SETl nonumber
"*****************************
"Set grep
"*****************************
If G: iswin = 1
Let grep_path = 'd:/gnuwin32/bin/grep.exe'
Let fgrep_path = 'd:/gnuwin32/bin/fgrep.exe'
Let egrep_path = 'd:/gnuwin32/bin/egrep.exe'
Endif
Nnoremap <silent> <F3>: grep <CR>
"*******************
"Nerdtree set
"*******************
"Set nerdtree curent dir
If G: iswin = 1
Cd d :\
Else
CD/home/zhaoyong
Endif
"Switch to the current directory
"Map <leader> Cd: cd %: P: H <CR>
Let G: nerdtree_title = "[nerd tree]"
Let nerdtreeshowbookmarks = 1 "always show bookmarks
Let nerdtreechdirmode = 2 "when you open the bookmarks, the vim PWD is automatically set as the Open Directory. If your project has a tags file, you will find this command very helpful.
Function! Nerdtree_start ()
EXE 'nerdtree'
Endfunction
Function! Nerdtree_isvalid ()
Return 1
Endfunction
NMAP <silent> <F2>: nerdtreetoggle <CR>
"NMAP <F4>: nerdtree <CR>
"*******************
"Fuzzyfinder
"*******************
Let G: fuf_modesdisable = []
Let G: fuf_mrufile_maxitem= 400
Let G: fuf_mrucmd_maxitem = 400
Let G: fuf_keyopen = '<CR>'
Let G: fuf_keyopensplit = '<c-j>'
Let G: fuf_keyopentabpage = '<c-l>'
Let G: fuf_datadir = $ vimfiles. "/fuf_data"
"Key Map for fuzzyfinder
Let mapleader = ","
Map <leader> FF: fuffile <CR>
Map <leader> FB: fufbuffer <CR>
"*******************
"Php languange set"
"*******************
"Set PHP document
Fun! Setphp ()
If & filetype = "php"
If G: iswin = 1
Set runtimepath + = D: \ Program \ files \ Vim \ php_doc
Else
Set runtimepath + =/home/zhaoyong/. Vim/php_doc
Endif
Endif
Autocmd bufwritepost *. php :! Php-l % <CR>
Endfun
Autocmd bufread, bufnewfile *. php, *. phtml call setphp ()
"*******************
"Python language set
"*******************
Fun! Setpython ()
If G: iswin = 1
"Set Python document
Let G: pyref_python = 'd: \ Program Files \ Vim \ Python-HTML'
"Pydiction
Let G: pydiction_location = 'd: \ Program Files \ Vim \ vim73 \ ftplugin \ pydiction \ complete-dict'
Else
Let G: pyref_python = '/home/zhaoyong/. Vim/Python-HTML'
Let G: pydiction_location = '/home/zhaoyong/. Vim/pydiction/complete-dict'
Endif
If & filetype = "Python"
"Exec Python
Map <F6> :! Python %
"Pythoncomplete C-X c-o
Endif
Endfun
Autocmd bufread, bufnewfile *. py call setpython ()
"*******************
"C/C ++ Language Set
"*******************
Fun! Setclang ()
If & filetype = "C" | & filetype = "CPP"
Set tags + = $ vimfiles/libstdc ++/tags
"Omnicomplete plugin
Let omnicpp_namespacesearch = 1
Let omnicpp_globalscopesearch = 1
Let omnicpp_showaccess = 1
Let omnicpp_showprototypeinabbr = 1 "show function parameter list
Let omnicpp_maycompletedot = 1 "input. Auto-completion
Let omnicpp_maycompletearrow = 1 "input-> auto-completion
Let omnicpp_maycompletescope = 1 "input: auto-completion
Let omnicpp_defaultnamespaces = ["STD", "_ glibcxx_std"]
"Auto-closing completion window
AU cursormovedi, insertleave * If pumvisible () = 0 | silent! Pclose | endif
Set completeopt = menuone, menu, longest"
Endif
If & filetype = 'C' | & filetype = 'cpp'
Inoremap [[] <ESC>: Let leavechar = "]" <CR> I
Inoremap {<ESC> O} <ESC>: Let leavechar = "}" <CR> O
Inoremap {{}< ESC >:let leavechar = "}" <CR> I
Inoremap () <ESC>: Let leavechar = ")" <CR> I
Inoremap ''' <ESC>: Let leavechar = "'" <CR> I
Inoremap "<ESC>: Let leavechar = '"' <CR> I
"Au bufnewfile, bufread *. \ (Vim \)\@! Inoremap "<ESC>: Let leavechar = '"' <CR> I
"Au bufnewfile, bufread *. \ (txt \)\@! Inoremap ''' <ESC>: Let leavechar = "'" <CR> I
"Imap <m-L> <ESC>: EXEC" normal F ". leavechar <CR>
"Imap <D-L> <ESC>: EXEC" normal F ". leavechar <CR>
Endif
Endfun
Autocmd bufread, bufnewfile *. C, *. H, *. cpp call setclang ()
"*******************
"Plugin GDB
"*******************
Run macros/gdb_mappings.vim
"*******************
"Plugin MRU
"Manage recently used files
"*******************
If G: iswin = 1
Let mru_file = 'd: \ myhome \ _ vim_mru_files'
Else
Let mru_file = '/home/zhaoyong/. Vim/mru_files'
Endif
"*******************
"SVN set
"*******************
"Update the code of the current directory
"Map <F6> :! SVN up <CR>
"Submit SVN (current directory)
"Map <F7> :! SVN ci-M ""
"Submit SVN (current file)
"Map <F8> :! SVN ci-M "" %
"*******************
"Supertab set
"*******************
"Let G: supertabretaincompletiontype = 2
"Let G: supertabdefacomplecompletiontype =" <C-X> <C-O>"
"Syntax highlight Function
Function! Togglesyntax ()
If exists ("G: syntax_on ")
Syntax off
Else
Syntax enable
Endif
Endfunction
"Shortcut for quick editing of vimrc files
If G: iswin = 1
Map <silent> <leader> E: e d: \ Program Files \ Vim \ _ vimrc <CR>
"When vimrc is saved, reload vimrc
Autocmd! Bufwritepost *. vimrc source D: \ Program Files \ Vim \ _ vimrc
Else
Map <silent> <leader> E: E ~ /. Vimrc <CR>
"When vimrc is saved, reload vimrc
Autocmd! Bufwritepost *. vimrc source ~ /. Vimrc
Endif
"Set the current working directory to the directory of the Buf File
Autocmd bufenter * LCD %: P: H
"The session is automatically saved before vim exits.
"If G: iswin = 0
"Let s: Path = '/home/zhaoyong/. Vim/session. Vim'
"Else
"Let s: Path = 'd: \ Program Files \ Vim \ Session. Vim'
"Endif
If G: iswin = 0 & has ("gui_running ")
"Disable minibuf, nerdtree, and tlist when you exit vim.
"Autocmd vimleave * \ MBT
Autocmd vimleave * nerdtreeclose
Autocmd vimleave * tlistclose
"Save session
"Autocmd vimleave * EXE" mksession! ". S: Path
"" Start automatic session Loading
"Autocmd vimenter * EXE" Source ". S: Path
Endif
"Show the correct man help info
If has ("gui_running ")
Runtime ftplugin/man. Vim
Nmap k: Man <cword> <CR>
Endif
"Use Ctrl + W to disable the current Cache
"Map <silent> <C-W> <c-k> d <CR> <c-j>
"Create a tag
Map <silent> <C-N>: enew <CR>
"Create a tab
Map <silent> <c-t>: tabnew <CR>
Map <silent> <c-S>: W <CR>
Imap <silent> <c-S> <ESC>: W <CR>
"Maximized window at startup
"Au guienter * simalt ~ X
Autocmd guienter * winpos 0 0 | set lines = 999 columns = 9999
"Close the current Buf
Map <silent> QQ: BD <CR>
"Clear search highlight
Map <silent> lymphoma/axkexiej <CR>
"Annotation ing key
Let mapleader = ","
Map <silent> <leader> L: Call nerdcomment (0, "toggle") <CR>
Map <silent> <leader> K: Call nerdcomment (0, "sexy") <CR>
"Ing the first and last rows
Map <silent> <leader> 1 1g
Map <silent> <leader> G gg
"Auto-complete brackets
"Map auto complete
"Inoremap () <ESC>: Let leavechar =") "<CR> I
"Set status line
Set statusline = % F % m % R % H % w \ [format = % {& ff}] \ [type = % Y] \ [ASCII = \ % 03.3b] \ [hex = \ % 02.2b] \ [Pos = % 04l, % 04 V] \ [% P %]
Set laststatus = 2
"Highlight the row where the cursor is located
"Set cursorline
Set nocul
"Toggle menu and toolbar
Map <silent> <C-F2>: IF & guioptions = ~ # 'T' <bar>
\ Set guioptions-= T <bar>
\ Set guioptions-= m <bar>
\ Else <bar>
\ Set guioptions + = T <bar>
\ Set guioptions + = m <bar>
\ Endif <CR>
"Set the short tab name
Function! Shorttablabel ()
Let bufnrlist = tabpagebuflist (V: lnum)
"Show only the first 6 letters of the name + ..
Let label = bufname (bufnrlist [tabpagewinnr (V: lnum)-1])
Let filename = fnamemodify (Label, ': H ')
"Only add .. If string is more than 8 letters
If strlen (filename)> = 8
Let ret = filename [0: 5]. '...'
Else
Let ret = filename
Endif
Return ret
Endfunction
"Simple implementation of the mouse prompt function
Function! Simpleballon ()
Return 'cursor is at line/column: '. V: beval_lnum.
\ '/'. V: beval_col.
\ 'In file'. bufname (V: beval_bufnr ).
\ '. Word under cursor is: "'. V: beval_text .'"'
Endfunction
"Set balloonexpr = simpleballon ()
"Set ballooneval
"Cscope
Map <F12>: Call do_cstag () <CR>
NMAP <c-@> S: CS find S <C-R> = expand ("<cword>") <CR>: Copen <CR>
NMAP <c-@> G: CS find G <C-R> = expand ("<cword>") <CR>
NMAP <c-@> C: CS find C <C-R> = expand ("<cword>") <CR>: Copen <CR>
NMAP <c-@> T: CS find t <C-R> = expand ("<cword>") <CR>: Copen <CR>
NMAP <c-@> E: CS find e <C-R> = expand ("<cword>") <CR>: Copen <CR>
NMAP <c-@> F: CS find F <C-R> = expand ("<cfile>") <CR>: Copen <CR>
NMAP <c-@> I: CS find I ^ <C-R> = expand ("<cfile>") <CR >$ <CR>: Copen <CR>
NMAP <c-@> D: CS find d <C-R> = expand ("<cword>") <CR>: Copen <CR>
Function! Do_cstag ()
Let dir = getcwd ()
If filereadable ("tags ")
If (G: iswin = 1)
Let tagsdeleted = Delete (dir. "\". "tags ")
Else
Let tagsdeleted = Delete ("./". "tags ")
Endif
If (tagsdeleted! = 0)
Echohl warningmsg | echo "fail to do tags! I cannot delete the tags "| echohl none
Return
Endif
Endif
If has ("CSAs ")
Silent! Execute "CS kill-1"
Endif
If filereadable ("cscope. Files ")
If (G: iswin = 1)
Let csfilesdeleted = Delete (dir. "\". "cscope. Files ")
Else
Let csfilesdeleted = Delete ("./". "cscope. Files ")
Endif
If (csfilesdeleted! = 0)
Echohl warningmsg | echo "fail to do cscope! I cannot delete the cshl. Files "| echohl none
Return
Endif
Endif
If filereadable ("cscope. Out ")
If (G: iswin = 1)
Let csoutdeleted = Delete (dir. "\". "csut. out ")
Else
Let csoutdeleted = Delete ("./". "csut. out ")
Endif
If (csoutdeleted! = 0)
Echohl warningmsg | echo "fail to do cscope! I cannot delete the cshl. Out "| echohl none
Return
Endif
Endif
If (executable ('ctags '))
"Silent! Execute "! Ctags-r -- c-types = + p -- fields = + S *"
Silent! Execute "! Ctags-r -- C ++-kinds = + p -- fields = + IAS -- extra = + Q ."
Endif
If (executable ('cs;') & has ("cs "))
If (G: iswin! = 1)
Silent! Execute "! Find. -name '*. h'-o-name '*. C '-o-name '*. CPP '-o-name '*. java '-o-name '*. CS '> csflood. files"
Else
Silent! Execute "! DIR/S/B *. C, *. cpp, *. H, *. Java, *. Cs> cs.pdf. Files"
Endif
Silent! Execute "! Cssag-B"
Execute "Normal :"
If filereadable ("cscope. Out ")
Execute "CS add csute. Out"
Endif
Endif
Endfunction