Vim Configuration Instructions

Source: Internet
Author: User
Tags define function set background

Vim is universally acknowledged to be very useful and perfect, but for beginners it is not easy to get started. Many programmers under Windows like the source Insight tool to look at the code, various syntax highlighting is very comfortable. As a programmer-created editor, Vim doesn't make sense for programmers to comfortably edit code, but it's often difficult for novices to configure it as a pleasing environment.


Users can customize the functionality of Vim by simply modifying the contents of the. VIMRC configuration file in the home directory.



You can replace the contents of the ~/.VIMRC with the following content, or, if necessary, modify it as needed ("The following content is the comment content"):

"" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Display Correlation," "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Set Shortmess=ati" does not show the prompt for Ugandan children "Winpos 5 5" Set window position "set lines=40 columns=155" Set window Size "    Set Nu "Show line number set go=" Do not have graphic button "color asmanian2" setting background theme sets Guifont=courier_new:h10:cansi "Set font" syntax on "syntax highlighting autocmd insertleave * se nocul" highlight current line autocmd insertenter * se cul "with light color high On the current line "set ruler" show ruler set showcmd "The input command is displayed, see clearly" set cmdheight=1 "command line (under the status line) height, set to 1" set    Whichwrap+=<,>,h,l "Allow the backspace and cursor keys to span row boundaries (not recommended)" set scrolloff=3 "cursor 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\ ")}" status line display contents set Laststatus=1 "Start Display status line (1), always show status line (2) Set foldenable" Allow collapse set foldmethod=manual "manual Collapse "Set Background=dark" background using black Set nocompatible "Remove nasty about VI consistency mode, avoid some bugs and limitations of previous versions" display Chinese help if version >= 603 set HELPLANG=CN set encoding=utf-8e NDIF "Set color scheme" ColorScheme Murphy "Font" if (Has ("gui_running")) "Set guifont=bitstream\ vera\ sans\ mono\" endif set fen Cs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936set Termencoding=utf-8set Encoding=utf-8set fileencodings= Ucs-bom,utf-8,cp936set fileencoding=utf-8 "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " ,*. [Ch],*.sh,*.java exec]: Call Settitle () "" "Define function Settitle, automatically insert file header func settitle ()" If the file type is. sh file if &filetype = = ' SH ' call Setline (1, "\#########################################################################") The call app End ("."), "\# 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 &AMp;filetype = = ' C ' Call append (".") +6, "#include <stdio.h>") Call Append (".") +7, "") endif "after new file, automatically navigates to end of file autocmd Bufnewfile * Normal Gendfunc" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "", "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" W:w!<cr>nmap <leader>f:find<cr> "Map Select all + copy Ctrl+amap <C-A> ggvgymap! <C-A> <esc>ggvgymap <F12> gg=g "Select Ctrl + C copy vmap <C-c>" +y "Go to Empty line Nnoremap <F2>: g/^\s*$/d& Lt Cr> "Compare files Nnoremap <C-F2>: Vert diffsplit" new label map <M-F2>:tabnew<cr> "lists the current directory file map <F3>: Tabnew .<cr> "Open 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 &am P;filetype = = ' cpp ' EXEC '!g++%-o%< ' exec '! ./%< ' elsEIF &filetype = = ' java ' exec "!javac%" exec "!java%<" elseif &filetype = = ' sh ':!. /% endifendfunc "c,c++ Debug map <F8>: Call Rungdb () <cr>func! Rungdb () Exec "W" exec "!g++%-g-o%<" exec "!gdb ./%<" Endfunc "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " Set automatically load set Autoread "Quickfix mode autocmd FileType c,cpp map <buffer> <leader><space>: W&LT;CR when file is changed >:make<cr> "Code completion set Completeopt=preview,menu" allows plug-ins filetype plugin on "shared clipboard set clipboard+=unnamed" Never back Up set n              Obackup "make run: Set makeprg=g++\-wall\ \%" Auto Save set Autowriteset ruler "open status bar ruler set Cursorline "Highlight Current line set Magic" set magic Set Guioptions-=t "Hide toolbar set guioptions-=m" Hide Menu bar "Set Statusline=\%<%f[%1*%m%*%n%r%h]%=\%y\%0 (%{&fileformat}\%{&encoding}\%c:%l/%L%) " Set in the shapeThe information set Foldcolumn=0set foldmethod=indent set foldlevel=3 set foldenable "Start collapsing" do not use VI's keyboard mode, but Vim's own set n Ocompatible "Syntax highlighting set Syntax=on" Get rid of input error prompt sound set Noeb "when processing unsaved or read-only files, pop-up confirm set confirm" Auto indent set Autoindentset cindent " Tab width Set tabstop=4 "Unified indentation is 4set softtabstop=4set shiftwidth=4" Do not use spaces instead of tab set noexpandtab "tab set Smarttab at the beginning of rows and segments" Display line numbers set number "history set history=1000" Prohibit generate temporary file set Nobackupset noswapfile "Search ignores case set ignorecase" Search Fugauliang set Hlsearchset Incsearch "Inline replace set Gdefault" encoding setting set Enc=utf-8set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 "language setting set Langmenu=zh_cn. Utf-8set HELPLANG=CN "My status line displays content (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 line set laststatus=2 "command line (under status line) height, default is 1, here is 2set cmdheight=2" reconnaissance file type filetype on "load file type plug-in filetype plugin on" Load the relevant indentation file for a specific file type filetype indent on "Save global variable set viminfo+=!" words with the following symbols do not split into linesSet iskeyword+=_,$,@,%,#,-"Putting inserted pixel number of lines set linespace=0" command line autocomplete in enhanced mode set Wildmenu "Make the BACKSPACE key (BACKSPACE) normal handling indent, EOL, Start and other set backspace=2 "Allow backspace and cursor keys to span the line boundary set Whichwrap+=<,>,h,l" You can use the mouse anywhere in buffer (similar to double-clicking the mouse in the workspace) set Mouse=aset selection=exclusiveset 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, easy to read set fillchars=vert:\, stl:\, STLNC:" Highlight matching parentheses set Showmatch " Matches the time of the brace highlighting (in a very second) set matchtime=1 "Keep 3 lines distance from set scrolloff=3" when the cursor moves to the top and bottom of the buffer "The C program provides auto indent set Smartindent" Highlight Plain 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>ifunction! Closepair (char) if getline ('. ')   [Col ('. ')-1] = = A:char return "\<right>" else return A:char Endifendfunctionfiletype plugin indent on "Open file type detection, add this to use the smart complement set Completeopt=longest,menu" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" Ctags Settings, "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "Let Tlist_sort_type =" name "" Sort by name let Tlist_use_right_window = 1 "On the right display window let Tl Ist_compart_format = 1 "compression Let Tlist_exist_onlywindow = 1" If there is only one buffer,kill window kill buffer Let tlist_file_fold_a Uto_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\ja Va\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 Set tags set tags=tags set autochdir "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" TagList "" "" Auto_open=1 "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" """ "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " "" "" "" "" "" "" Let Tlist_ctags_cmd = '/usr/bin/ctags ' Let Tlist_show_one_file = 1 "does not display multiple file tags at the same time, only show let tlist_exit_ of the current file Onlywindow = 1 "If the TagList window is the last window, then exit vim let Tlist_use_right_window = 1" Show TagList window in the right window "MINIBUFEXPL plug-in general settings let G: Minibufexplmapwindownavvim = 1let G:minibufexplmapwindownavarrows = 1let G:minibufexplmapctabswitchbufs = 1let g: Minibufexplmodseltarget = 1

VIM configuration mainly has the following characteristics :
1, press F5 can directly compile and execute C, C + +, Java code and execute shell script, press "F8" to debug C, C + + code

2, automatically insert the file header, new C, C + + source files automatically inserted header: including the file name, author, contact, establishment time, etc., the reader can change according to the needs of their own

3. Map "Ctrl + A" To select All and copy shortcut keys for easy copying of code

4, press "F2" can directly eliminate the blank line in the code

5, "F3" can list the current directory files, open the tree-like file directory

6, support mouse selection, direction key movement

7, code highlighting, automatic indentation, display line number, display status line

8. Press "Ctrl + P" to complete the auto-completion


9, [], {}, (), "", "and so on are fully automatic completion


10. Other function readers can study the following documents


Turn from: Powerful vim configuration file, make programming more casual

Vim Configuration Instructions

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.