Complete VIM configuration

Source: Internet
Author: User
Tags eol
General settings default decoding setfencutf-8setfencsutf-8, usc-bom, euc-jp, gb18030, gbk, gb2312, cp936 """"""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""
"General settings
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Set default decoding
Set fenc = UTF-8
Set fencs = UTF-8, usc-bom, euc-jp, gb18030, gbk, gb2312, cp936

"Do not use the vi keyboard mode, but vim's own
Set nocompatible

"Number of lines to be recorded in the history file
Set history = 100

"Confirmation pops up when processing unsaved or read-only files
Set confirm

"Share clipboard with windows
Set clipboard + = unnamed

"File type detection
Filetype on

"Load file type plug-in
Filetype plugin on

"Load indent files for a specific file type
Filetype indent on

"Save Global variables
Set viminfo + =!

"Do not separate words with the following symbols by line breaks
Set iskeyword + =_, $, @, % ,#,-

"Syntax highlighting
Syntax on

"Highlight characters, so it is not limited to 100 columns
: Highlight OverLength ctermbg = red ctermfg = white guibg = redguifg = white
: Match OverLength '\ % 101 v .*'

"Status line color
Highlight StatusLine guifg = SlateBlue guibg = Yellow
Highlight StatusLineNC guifg = Gray guibg = White

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"File settings
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Do not back up files (choose as needed)
Set nobackup

"Do not generate a swap file. hide it when the buffer is discarded.
Setlocal noswapfile
Set bufhidden = hide

"Number of pixel rows inserted between characters
Set linespace = 0

"The command line in enhanced mode automatically completes the operation
Set wildmenu

"Display the row number and column number at the cursor position on the status line
Set ruler
Set rulerformat = % 20 (% 2 * % <% f % = \ % m % r \ % 3l \ % c \ % p %)

"The height of the command line (under the status line). The default value is 1. here is 2.
Set bytes height = 2

"Enable backspace to process indent, eol, start, and so on.
Set backspace = 2

"Allow backspace and cursor keys to span row boundaries
Set whichwrap + = <,>, h, l

"You can use the mouse anywhere in the buffer (similar to double-click the mouse in the workspace in office to locate the location)
Set mouse =
Set selection = exclusive
Set selectmode = mouse, key

"The prompt for assistance to children in Somalia is not displayed at startup.
Set shortmess = atI

"The commands command tells us which row of the file has been changed.
Set report = 0

"Don't let vim sound annoying.
Set noerrorbells

"White space is displayed between split windows for ease of reading
Set fillchars = vert: \, stl: \, stlnc :\

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Search and match
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Highlight matching brackets
Set showmatch

"Matching the time when brackets are highlighted (unit: 10 seconds)
Set matchtime = 5

"Case insensitive during search
Set ignorecase

"Do not highlight the searched sentence (phrases)
Set nohlsearch

"When searching, the entered words are highlighted by character (similar to firefox search)
Set incsearch

"Input: What should the set list command display?
Set listchars = tab: \ | \, trail:., extends:>, precedes: <, eol: $

"Move the cursor to the top and bottom of the buffer to keep the distance between three rows
Set scroloff = 3

"Do not flash
Set novisualbell

"Content displayed in my status line (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 \")}

"Always show status line
Set laststatus = 2

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Text format and layout
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Automatic formatting
Set formatoptions = tcrqn

"Inherits the indentation of the previous line, especially for Multiline comments.
Set autoindent

"Provides automatic indentation for C programs
Set smartindent

"Use C-style indent
Set cindent

"Tab: 4
Set tabstop = 4

"Unified indent to 4
Set softtabstop = 4
Set shiftwidth = 4

"Do not use spaces instead of tabs
Set noexpandtab

"Do not wrap
Set nowrap

"Use a tab at the beginning of a row and segment
Set smarttab

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"CTags settings
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"Sort by name
Let Tlist_Sort_Type = "name"

"Display window on the right
Let Tlist_Use_Right_Window = 1

"Compression mode
Let Tlist_Compart_Format = 1

"If there is only one buffer, the kill window also kill the buffer.
Let Tlist_Exist_OnlyWindow = 1

"Do not close the tags of other files
Let Tlist_File_Fold_Auto_Close = 0

"Do not show the folding tree
Let Tlist_Enable_Fold_Column = 0

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"The row number is displayed only when the following file types are detected. normal text files are not displayed.

If has ("autocmd ")
Autocmd FileTypexml, html, c, cs, java, perl, shell, bash, cpp, python, vim, php, ruby setnumber
Autocmd FileType xml, html vmap ' O '> O -->
Autocmd FileType java, c, cpp, cs vmap ' '> O */
Autocmd FileTypehtml, text, php, vim, c, java, xml, bash, shell, perl, python setlocaltextwidth = 100
Autocmd Filetype html, xml, xsl source $ VIMRUNTIME/plugin/closetag. vim
Autocmd BufReadPost *
\ If line ("'\" ")> 0 & line ("' \ "") <= line ("$") |
\ Exe "normal G' \" "|
\ Endif
Endif "has (" autocmd ")

"F5 compiles and runs C programs, F6 compiles and runs C ++ programs
"Please note that an error will be reported when the following code is used in windows.
"Remove the./characters.

"C compilation and running
Map : Call CompileRunGcc ()
Func! CompileRunGcc ()
Exec "w"
Exec "! Gcc %-o % <"
Exec "! ./% <"

"C ++ compilation and running
Map : Call CompileRunGpp ()
Func! CompileRunGpp ()
Exec "w"
Exec "! G ++ %-o % <"
Exec "! ./% <"

"The. NFO file can be beautifully displayed.
Set encoding = UTF-8
Function! SetFileEncodings (encodings)
Let B: myfileencodingsbk = & fileencodings
Let & fileencodings = a: encodings
Function! RestoreFileEncodings ()
Let & fileencodings = B: myfileencodingsbk
Unlet B: myfileencodingsbk

Au BufReadPre *. nfo call SetFileEncodings ('cp437') | setambiwidth = single
Au BufReadPost *. nfo call RestoreFileEncodings ()

"Highlight common txt files (txt. vim script is required)
Au BufRead, BufNewFile * setfiletype txt

"Use the space key to switch and collapse
Set foldenable
Set foldmethod = manual
Nnoremap @ = (Foldclosed (line ('.') <0 )? 'Zc': 'Z ')

"General settings of the minibufexpl plug-in
Let g: miniBufExplMapWindowNavVim = 1
Let g: miniBufExplMapWindowNavArrows = 1
Let g: miniBufExplMapCTabSwitchBufs = 1
Let g: miniBufExplModSelTarget = 1

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: 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.