Vim settings (very comprehensive), that is, the configuration of the. vimrc file

Source: Internet
Author: User
Tags define function set background sorted by name
1. In the terminal use Vim for editing, by default, the editing interface is not displayed line number, syntax high-brightness display, intelligent indentation and other functions. In order to better work under VIM, you need to manually set a profile:. vimrc.

When Vim is started, the. vimrc file in the current user root directory is automatically read, and the file can contain settings and even scripts, so it is generally convenient to create a. vimrc file under the current user's root directory, that is, the command created is:

$vi ~/.VIMRC

2. Then paste the following option settings:




Syntax on "Automatic syntax highlighting
"Winpos 5 5" Set window position
"Set lines=40 columns=155" setting window size
Set Nu Show Line numbers
Set go= "Do not have graphic buttons
"Color asmanian2" setting background theme
Set Guifont=courier_new:h10:cansi font
"Syntax on" syntax highlighting
Autocmd insertleave * se nocul "highlight with light
Autocmd insertenter * se cul "highlight with light
Set ruler "show rulers
Set ShowCmd "The command entered is 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 cross line boundaries (not recommended)
The "set scrolloff=3" cursor moves to the top and bottom of the buffer to maintain a distance of 3 lines
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
The "set Background=dark" background uses black
Set nocompatible "Get rid of annoying about VI consistency mode, avoid some bugs and limitations of previous versions
"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
Sets Fileencoding=utf-8 "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "," "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" """"""""
"" "New File title" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
"New. c,.h,.sh,.java file, insert File header automatically
Autocmd bufnewfile *.cpp,*. [Ch],*.sh,*.java Exec ": Call Settitle ()"
"" Define function Settitle, insert file headers automatically
Func Settitle ()
"If the file type is. sh file
if &filetype = = ' sh '
Call Setline (1, "\#########################################################################")
Call Append ("."), "\# File Name:". Expand ("%"))
Call Append (Line (".") +1, "\# author:zll")
Call Append (Line (".") +2, "\# mail:zhnlion@126.com")
Call Append (Line (".") +3, "\# Created Time:". Strftime ("%c"))
Call Append (Line (".") +4, "\#########################################################################")
Call Append (Line (".") +5, "\#!/bin/bash")
Call Append (Line (".") +6, "")
Else
Call Setline (1, "/*************************************************************************")
Call Append ("."), "> File Name:". Expand ("%")
Call Append (Line (".") +1, "> Author:zll")
Call Append (Line (".") +2, "> mail:zhnllion@126.com")
Call Append (Line (".") +3, "> Created time:". Strftime ("%c")
Call Append (Line (".") +4, "************************************************************************/")
Call Append (Line (".") +5, "")
endif
if &filetype = = ' cpp '
Call Append (Line (".") +6, "#include <iostream>")
Call Append (Line (".") +7, "using namespace std;")
Call Append (Line (".") +8, "")
endif
if &filetype = = ' C '
Call Append (Line (".") +6, "#include <stdio.h>")
Call Append (Line (".") +7, "")
endif
"Automatically navigates to end of file after new file
Autocmd Bufnewfile * Normal G
Endfunc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
The keyboard command
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Nmap <leader>w:w!<cr>
Nmap <leader>f:find<cr>


"Map 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 to the empty line
Nnoremap <F2>:g/^\s*$/d<cr>
The Compare file
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 file directory
Map <C-F3> \be
"C,c++ Press F5 compile 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
"C,c++ 's Debugging
Map <F8>: Call Rungdb () <CR>
func! Rungdb ()
Exec "W"
Exec "!g++%-g-o%<"
Exec "!gdb ./%<"
Endfunc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Utility settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Set to load automatically when a file is changed
Set Autoread
"Quickfix mode
Autocmd FileType c,cpp map <buffer> <leader><space>:w<cr>:make<cr>
The code-completion
Set Completeopt=preview,menu
"Allow Plug-ins
FileType plugin on
The Share clipboard
Set clipboard+=unnamed
"Never Back Up
Set Nobackup
"Make runs
: Set makeprg=g++\-wall\ \%
The Auto Save
Set Autowrite
Set ruler Open the status bar ruler
Set Cursorline "Highlight when forward
Set Magic "Setting 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
"Do not use VI keyboard mode, but vim own
Set nocompatible
The syntax highlights
Set Syntax=on
"Remove the sound of the input error
Set Noeb
"Eject confirmation when processing unsaved or read-only files
Set confirm
The Auto Indent
Set Autoindent
Set Cindent
The width of the TAB key
Set tabstop=4
"Unified indent to 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
"Show line numbers
Set number
"History number
Set history=1000
"Prohibit generation of temporary files
Set Nobackup
Set Noswapfile
"Search ignores case
Set ignorecase
"Search 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
"The content that my status line displays (including file types 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 line
Set laststatus=2
The height of the command line (under the status line), defaults to 1, here is 2
Set cmdheight=2
"Reconnaissance file type
FileType on
The Load file type plug-in
FileType plugin on
"Load a related indent file for a specific file type
FileType indent on
"Save Global variables
Set viminfo+=!
"Words with the following symbols should not be separated by line breaking
Set iskeyword+=_,$,@,%,#,-
"Character Fu the number of pixel rows inserted
Set linespace=0
Automatic command line completion in enhanced mode
Set Wildmenu
"Make The Back Space bar (BACKSPACE) normal processing indent, EOL, start, etc.
Set backspace=2
"Allows backspace and cursor keys to cross line boundaries
Set Whichwrap+=<,>,h,l
"You can use the mouse anywhere in the buffer (similar to double-clicking the mouse in the workspace in office)
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
"Displays whitespace between partitioned windows for easy reading
Set Fillchars=vert:\, Stl:\, Stlnc:\
"Highlight matching brackets
Set Showmatch
"Match the time of the brace highlighting (in a very second)
Set matchtime=1
"The cursor moves to the top and bottom of the buffer to maintain a distance of 3 lines
Set scrolloff=3
"Provides automatic indentation for C programs
Set Smartindent
"Highlight plain TXT file (requires Txt.vim script)
Au bufread,bufnewfile * Setfiletype txt
The auto-complement
: 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 intelligent
Set Completeopt=longest,menu
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Ctags's setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Let Tlist_sort_type = "name" Sorted by name
Let Tlist_use_right_window = 1 "Display the window on the right
Let Tlist_compart_format = 1 "compression mode
Let Tlist_exist_onlywindow = 1 "If only one buffer,kill window also kill buffer
Let Tlist_file_fold_auto_close = 0 "Do not close tags for other files
Let Tlist_enable_fold_column = 0 "Do not show the collapse 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
"Set tags
Set Tags=tags
"Set Autochdir


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Other Stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Open TagList By default
Let Tlist_auto_open=1
""""""""""""""""""""""""""""""
"Tag list" (ctags)
""""""""""""""""""""""""""""""""
Let Tlist_ctags_cmd = '/usr/bin/ctags '
Let Tlist_show_one_file = 1 "does not display tag for multiple files at the same time, displays only the current file
Let Tlist_exit_onlywindow = 1 "If the TagList window is the last window, then quit VIM
Let Tlist_use_right_window = 1 "Display TagList window in the right window
The general settings for the MINIBUFEXPL plug-in
Let G:minibufexplmapwindownavvim = 1
Let G:minibufexplmapwindownavarrows = 1
Let G:minibufexplmapctabswitchbufs = 1
Let G:minibufexplmodseltarget = 1



3. After setting up

$:x or $:WQ.

To save and exit.


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.