Recently transferred from the IDE to vim, a lot of habits inconsistent, specially configured a vim environment. On the Internet to find the great God's post, afraid to forget, hereby commemorate.
Portal Http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html
How to use: Create a new folder under the home directory of your personal account, named: ". VIMRC" (Note that there is a point, but the configuration is over, the file seems to be hidden.) )
The following is the detailed code, the comments are clear, can be targeted to use a few commands.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
The show related
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Set Shortmess=ati" does not display the reminder to help Ugandan children when it starts
"Winpos 5 5" Setting window position
"Set lines=40 columns=155" setting window size
"Set Nu" displays line numbers
Set go= "Do not graph button
"Color asmanian2" setting background theme
Set Guifont=courier_new:h10:cansi "Setting font
"Syntax on" syntax highlighting
Autocmd insertleave * se nocul "highlight when moving forward with light
Autocmd insertenter * se cul "highlight when moving forward with light
"Set ruler" display ruler
Set showcmd "Input command displayed, see clearly
The height of the "set cmdheight=1" command line (under the status line), set to 1
"Set Whichwrap+=<,>,h,l" allows backspace and cursor keys to span line boundaries (not recommended)
The "set scrolloff=3" cursor moves to the top and bottom of buffer to maintain 3 lines of distance
Set Novisualbell "Do not blink (do not understand)
Set statusline=%f%m%r%h%w\ [format=%{&ff}]\ [type=%y]\ [pos=%l,%v][%p%%]\%{strftime (\ "%d/%m/%y\-\%H:%M\")} " What the status line displays
Set Laststatus=1 "Start Display status line (1), always show status line (2)
Set foldenable "Allow folding
Set foldmethod=manual "Manual folding
"Set Background=dark" background using black
Set nocompatible "Remove nasty about VI consistency mode, avoid some bugs and limitations of previous versions
The show Chinese help
If version >= 603
Set HELPLANG=CN
Set Encoding=utf-8
endif
The Set color scheme
"ColorScheme Murphy
The font
"If (Has (" gui_running "))
"Set guifont=bitstream\ vera\ sans\ mono\ 10
"EndIf
Set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
Set Termencoding=utf-8
Set Encoding=utf-8
Set fileencodings=ucs-bom,utf-8,cp936
Set Fileencoding=utf-8
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" "" "" "New File title" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "
"Create a new. c,.h,.sh,.java file, insert the file header automatically
Autocmd bufnewfile *.cpp,*. [Ch],*.sh,*.java exec]: Call Settitle () "
"" Define function Settitle, insert file header automatically
Func Settitle ()
"If the file type is. sh file
if &filetype = = ' sh '
Call Setline (1, "\#########################################################################")
Call Append ("."), "\# File Name:". Expand ("%"))
Call Append (".") +1, "\# author:ma6174")
Call Append (".") +2, "\# Mail: [email protected]")
Call Append (".") +3, "\# Created Time:". Strftime ("%c"))
Call Append (".") +4, "\#########################################################################")
Call Append (".") +5, "\#!/bin/bash")
Call Append (".") +6, "")
Else
Call Setline (1, "/*************************************************************************")
Call Append ("."), "> File Name:" Expand ("%"))
Call Append (".") +1, "> author:ma6174")
Call Append (".") +2, "> Mail: [email protected]")
Call Append (".") +3, "> Created time:". Strftime ("%c"))
Call Append (".") +4, "************************************************************************/")
Call Append (".") +5, "")
endif
if &filetype = = ' cpp '
Call Append (".") +6, "#include <iostream>")
Call Append (".") +7, "using namespace std;")
Call Append (".") +8, "")
endif
if &filetype = = ' C '
Call Append (".") +6, "#include <stdio.h>")
Call Append (".") +7, "")
endif
"Automatically navigates to the end of a file after you create a new file
Autocmd Bufnewfile * Normal G
Endfunc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
The keyboard command
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Nmap <leader>w:w!<cr>
Nmap <leader>f:find<cr>
"Map Select all + Copy Ctrl + A
Map <C-A> Ggvgy
map! <C-A> <esc>ggvgy
Map <F12> gg=g
"CTRL + C copy in selected state
Vmap <C-c> "+y
"Go empty line
Nnoremap <F2>:g/^\s*$/d<cr>
The Compare files
Nnoremap <C-F2>: Vert diffsplit
The new label
Map <M-F2>:tabnew<cr>
"Lists the current directory files
Map <F3>: Tabnew .<cr>
"Open the tree-like file directory
Map <C-F3> \be
"C,c++ Press F5 to compile and run
Map <F5>: Call COMPILERUNGCC () <CR>
func! COMPILERUNGCC ()
Exec "W"
if &filetype = = ' C '
Exec "!g++%-O%<"
EXEC "! ./%<"
ElseIf &filetype = = ' cpp '
Exec "!g++%-O%<"
EXEC "! ./%<"
ElseIf &filetype = = ' java '
Exec "!javac%"
Exec "!java%<"
ElseIf &filetype = = ' sh '
:!. /%
endif
Endfunc
"Commissioning of the C,c++
Map <F8>: Call Rungdb () <CR>
func! Rungdb ()
Exec "W"
Exec "!g++%-g-o%<"
Exec "!gdb ./%<"
Endfunc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Utility settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Set to automatically load when files are changed
Set Autoread
"Quickfix mode
Autocmd FileType c,cpp map <buffer> <leader><space>:w<cr>:make<cr>
The Code completion
Set Completeopt=preview,menu
The Allow plugins
FileType plugin on
The Share clipboard
Set clipboard+=unnamed
"Never Back Up
Set Nobackup
The Make Run
: Set makeprg=g++\-wall\ \%
The Auto Save
Set Autowrite
Set ruler "Open the status bar ruler
Set Cursorline "highlight when moving forward
Set Magic
Set Guioptions-=t "Hide the toolbar
Set guioptions-=m "Hide Menu bar
"Set statusline=\%<%f[%1*%m%*%n%r%h]%=\%y\%0 (%{&fileformat}\%{&encoding}\%c:%l/%L%) \
"Sets the information displayed in the status line
Set foldcolumn=0
Set Foldmethod=indent
Set foldlevel=3
Set foldenable "Start folding
"Don't use VI's keyboard mode, but Vim's own
Set nocompatible
The syntax highlighting
Set Syntax=on
"Remove the sound of input errors
Set Noeb
"When working with unsaved or read-only files, pop-up confirmation
Set confirm
The Auto Indent
Set Autoindent
Set Cindent
The width of the TAB key
Set tabstop=4
"Unified Indentation is 4
Set softtabstop=4
Set shiftwidth=4
"Do not use spaces instead of tabs
Set Noexpandtab
Use tabs at the beginning of rows and segments
Set Smarttab
The Display line number
Set number
"Number of historical records
Set history=1000
"Prohibit generation of temporary files
Set Nobackup
Set Noswapfile
"Search ignores case
Set ignorecase
"Search for verbatim Fugauliang
Set Hlsearch
Set Incsearch
"In-line substitution
Set Gdefault
The Encoding settings
Set Enc=utf-8
Set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
The Language settings
Set LANGMENU=ZH_CN. UTF-8
Set HELPLANG=CN
"My status line displays the contents (including file type and decoding)
"Set statusline=%f%m%r%h%w\ [format=%{&ff}]\ [type=%y]\ [pos=%l,%v][%p%%]\%{strftime (\"%d/%m/%y\-\%H:%M\ ")}
"Set statusline=[%f]%y%r%m%*%=[line:%l/%l,column:%c][%p%%]
"Always Show status lines
Set laststatus=2
The height of the command line (under the status line), which defaults to 1, here is 2
Set cmdheight=2
"Detect file Types
FileType on
"Load file type plug-in
FileType plugin on
"Loading related indentation files for a specific file type
FileType indent on
"Save Global variables
Set viminfo+=!
"Words with the following symbols are not separated by line breaks
Set iskeyword+=_,$,@,%,#,-
The number of pixel lines inserted by the word putting
Set linespace=0
"Command-line auto-complete operation in enhanced mode
Set Wildmenu
"Make the Back bar (BACKSPACE) normal handling indent, EOL, start, etc.
Set backspace=2
"Allow backspace and cursor keys to span line boundaries
Set Whichwrap+=<,>,h,l
"You can use the mouse anywhere in the buffer (similar to the workspace in office, double-click the mouse to navigate)
Set Mouse=a
Set selection=exclusive
Set Selectmode=mouse,key
"By using: Commands command, tell us which line of the file has been changed
Set report=0
"Display whitespace between split windows for easy reading
Set Fillchars=vert:\, Stl:\, Stlnc:\
"Highlight matching parentheses
Set Showmatch
"Matches the time of the parentheses highlighting (in a very second)
Set matchtime=1
"Keep 3 lines away when the cursor moves to the top and bottom of the buffer
Set scrolloff=3
"Provides automatic indentation for C programs
Set Smartindent
"Highlight normal TXT file (requires Txt.vim script)
Au bufread,bufnewfile * Setfiletype txt
"Auto-complete
: Inoremap (() <esc>i
: Inoremap) <c-r>=closepair (') ') <CR>
: inoremap {{<cr>}<esc>o
: Inoremap} <c-r>=closepair ('} ') <CR>
: Inoremap [[]<esc>i
: Inoremap] <c-r>=closepair ('] ') <CR>
: Inoremap "" "<esc>i
: Inoremap ' <esc>i
function! Closepair (char)
If Getline ('. ') [Col ('. ')-1] = = A:char
Return "\<right>"
Else
Return A:char
endif
Endfunction
FileType plugin indent on
"Open File type detection, add this sentence can be used to complete the smart
Set Completeopt=longest,menu
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"The setting of the Ctags
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Let Tlist_sort_type = "name" "Sort by name"
Let Tlist_use_right_window = 1 "Display window on the right
Let Tlist_compart_format = 1 "compression mode
Let Tlist_exist_onlywindow = 1 "Kill buffer if only one buffer,kill window is killed
Let Tlist_file_fold_auto_close = 0 "Do not close other files of tags
Let Tlist_enable_fold_column = 0 "Do not show collapsed tree
Autocmd FileType Java Set tags+=d:\tools\java\tags
"Autocmd FileType h,cpp,cc,c set Tags+=d:\tools\cpp\tags
"Let tlist_show_one_file=1" does not display the tag of multiple files at the same time, only displays the current file's
The Set tags
Set Tags=tags
The Set Autochdir
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Other Stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
The default open TagList
Let Tlist_auto_open=1
""""""""""""""""""""""""""""""
"Tag list (ctags)
""""""""""""""""""""""""""""""""
Let Tlist_ctags_cmd = '/usr/bin/ctags '
Let Tlist_show_one_file = 1 "does not display the tag of multiple files at the same time, only displays the current file's
Let Tlist_exit_onlywindow = 1 "If the TagList window is the last window, exit vim
Let Tlist_use_right_window = 1 "Displays the TagList window in the right window
"General settings for the MINIBUFEXPL plugin
Let G:minibufexplmapwindownavvim = 1
Let G:minibufexplmapwindownavarrows = 1
Let G:minibufexplmapctabswitchbufs = 1
Let G:minibufexplmodseltarget = 1
Configuration of the VIM standard environment