Vim general settings

Source: Internet
Author: User
Tags eol
If you do not know the location of the configuration file and script, run the following command in VIM: scriptnames: path/etc/vimrc/usr/share/Vim/vim72/syntax. vim/usr/share/Vim/vim72/syntax/synload. vim/usr/share/Vim/vim72/syntax/syncolor. vim/usr/share/Vim/vim72/filetype. vim/usr/share/Vim/vim72/ftplugin. vim/home/kdj /. vimrc

 

~ $ Cat. vimrc

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"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

"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 + =!

"Syntax highlighting
Syntax on

"Status line color
Highlight statusline guifg = slateblue guibg = yellow
Highlight statuslinenc guifg = gray guibg = white

"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

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

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"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

"""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""
"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

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

If has ("autocmd ")
Autocmd filetype XML, HTML, C, Cs, Java, Perl, Shell, Bash, CPP, Python, Vim, PHP, ruby set number
Autocmd filetype XML, HTML vmap <c-o> <ESC> '<I <! -- <ESC> O <ESC> '> O -->
Autocmd filetype Java, C, CPP, CS vmap <c-o> <ESC> '<o/* <ESC>'> O */
Autocmd filetype HTML, text, PHP, Vim, C, Java, XML, Bash, Shell, Perl, Python setlocal textwidth = 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 <F5>: Call compilerungcc () <CR>
Func! Compilerungcc ()
Exec "W"
Exec "! GCC %-o % <"
Exec "! ./% <"
Endfunc

"C ++ compilation and running
Map <F6>: Call compilerungpp () <CR>
Func! Compilerungpp ()
Exec "W"
Exec "! G ++ %-o % <"
Exec "! ./% <"
Endfunc

"The. nfo file can be beautifully displayed.
Set encoding = UTF-8
Function! Setfileencodings (encodings)
Let B: myfileencodingsbk = & fileencodings
Let & fileencodings = A: encodings
Endfunction
Function! Restorefileencodings ()
Let & fileencodings = B: myfileencodingsbk
Unlet B: myfileencodingsbk
Endfunction

AU bufreadpre *. nfo call setfileencodings ('cp437') | set ambiwidth = single
AU bufreadpost *. nfo call restorefileencodings ()

 

Settings I used here

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.