It took a long time to tidy up, feel very convenient to use, share.
My VIM configuration mainly has the following advantages:
1. Press F5 can directly compile and execute C, C + +, Java code and execute shell script, press "F8" can do C, C + + code debugging
2. Automatically insert the header of the file, new C, C + + source files automatically insert the header: including file name, author, contact, establishment time, etc., the reader can change according to the requirements
3. Map "Ctrl + A" To select All and copy shortcut keys to facilitate the copying of code
4. Press "F2" to directly eliminate blank lines in code
5. "F3" can list the current directory files, open the tree file directory
6. Support mouse selection, direction key movement
7. Code highlighting, automatic indentation, display line number, show status line
8. Press "Ctrl + P" to automatically fill the whole
9.[], {}, (), "," and so on are automatically filled
10. Other functions readers can study the following documents
Vim is a very powerful, very convenient editor, plus my code will certainly be doubled, perhaps the reader to use other programming languages, can be modified according to their needs, the configuration file has been added comments.
The reader is interested in copying the following code directly into a text file, and then renaming the file as ". VIMRC" (Don't Forget the "." in front), and then put the file under the root directory of the user's folder. Re-open Vim to see the effect.
For the convenience of management, the source code hosted to the GitHub, later added a lot of new features,
Specific details: Https://github.com/ma6174/vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
The show related
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Set Shortmess=ati" does not show the prompt to assist Ugandan children when it starts
"Winpos 5 5" Set window position
"Set lines=40 columns=155" setting window size
"Set Nu" shows 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" display 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\]} "status What the row 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:ma6174")
Call Append (Line (".") + 2, "\# mail:ma6174@163.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:ma6174")
Call Append (Line (".") + 2, "> mail:ma6174@163.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
: