VIM Quick Configuration C++,python Environment

Source: Internet
Author: User
Tags eol imap set background



Configure the VIM environment with one click with a profile written by a master on GitHub



-------------------------------------------------------------------------------------



Introduction See this blog: http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html



GitHub site: Https://github.com/ma6174/vim



--------------------------------------------------------------------------------------



In order to facilitate C++,python programming, I have added a mix of small brother GitHub on the configuration files and thin configuration files, joined the shortcut key compiler C++,python, etc., share the ~


Set sw=4
Set ts=4
Set et
Set smarttab
set smartindent
Set LBR
Set fo+=mB
Set SM
set selection=inclusive
Set wildmenu
set mousemodel=popup
au FileType php setlocal dict+=~/.vim/dict/php_funclist.dict
au FileType css setlocal dict+=~/.vim/dict/css.dict
au FileType c setlocal dict+=~/.vim/dict/c.dict
au FileType cpp setlocal dict+=~/.vim/dict/cpp.dict
au FileType scale setlocal dict+=~/.vim/dict/scale.dict
au FileType javascript setlocal dict+=~/.vim/dict/javascript.dict
au FileType html setlocal dict+=~/.vim/dict/javascript.dict
au FileType html setlocal dict+=~/.vim/dict/css.dict
"
"Syntastic correlation
execute pathogen#infect()
let g:syntastic_python_checkers=[‘pylint‘]
let g:syntastic_php_checkers=[‘php‘, ‘phpcs‘, ‘phpmd‘]
"Golang
"Processing... % (ctrl+c to stop)
let g:fencview_autodetect=0
set rtp+=$GOROOT/misc/vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Show related
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Syntax on
Set cul "highlight the line of the cursor
Set CUC
Set shortcuts = ATI "do not display the prompt to help Ugandan children when starting
Set go = "do not graph buttons
"Color desert" setting background theme
Color Ron "set background theme
"Color Tote" setting background theme
"Set guifont = Courier Ou new: H10: canis" set font
"Autocmd insertleave * se nocul" highlights the current line in light color
Autocmd insertenter * se cul "highlights the current line in light color
Set ruler "display ruler
Set showcmd "the input command is displayed, and it can be seen clearly
"Set which wrap + = <, >, h, l" allows backspace and cursor keys to cross line boundaries (not recommended)
Set scrolloff = 3 "keep 3 lines when the cursor moves to the top and bottom of the buffer
Set statusline =% F% m% R% H% w \ [format =% {&amp; FF}] \ [type =% y] \ [POS =% L,% v] [% P%%] \% {strftime (\% D /% m /% Y \ - \% H:% m \ ")}" what the status line shows
Set laststatus = 2 "start display status line (1), always display status line (2)
"Set foldenable" allows folding
"Set foldmethod = manual" manual folding
Set nocompatible "remove the annoying VI consistency pattern and avoid some bugs and limitations of previous versions
"Display help in Chinese
if version >= 603
set helplang=cn
set encoding=utf-8
Endif
"Auto indent
set autoindent
Set cindent
Tab width
set tabstop=4
"Indent uniformly to 4
set softtabstop=4
set shiftwidth=4
"Use spaces instead of tabs
set expandtab
"Use tabs at the beginning of rows and segments
Set smarttab
"Display line number
Set number
"Number of history records
set history=1000
"Search for character by character highlighting
Set hlsearch
set incsearch
"Language settings
set langmenu=zh_CN.UTF-8
set helplang=cn
"Always show status lines
set cmdheight=2
"Detect file types
Filetype on
"Load file type plug-in
filetype plugin on
"Load related indented files for specific file types
filetype indent on
"Save global variables
set viminfo+=!
"Do not break words with the following symbols
set iskeyword+=_,$,@,%,#,-
"Number of pixel lines inserted between characters
"Markdown configuration
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}   set filetype=mkd
au BufRead,BufNewFile *.{go}   set filetype=go
au BufRead,BufNewFile *.{js}   set filetype=javascript
"rkdown to HTML
nmap md :!~/.vim/markdown.pl % > %.html <CR><CR>
nmap fi :!firefox %.html &amp; <CR><CR>
Nmap \ \cc
VMap \ \cc
"Replace tab with space
nmap tt :%s/\t/    /g<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" new file title
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Create a new. C,. H,. Sh,. Java file and insert the file header automatically
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.rb,*.java,*.py exec ":call SetTitle()"
"" defines the settitle function, which automatically inserts the file header
func SetTitle()
"If the file type is. Sh file
if &amp;filetype == ‘sh‘
call setline(1,"\#!/bin/bash")
call append(line("."), "")
elseif &amp;filetype == ‘python‘
call setline(1,"#!/usr/bin/env python")
call append(line("."),"# coding=utf-8")
call append(line(".")+1, "")
elseif &amp;filetype == ‘ruby‘
call setline(1,"#!/usr/bin/env ruby")
call append(line("."),"# encoding: utf-8")
call append(line(".")+1, "")
"    elseif &amp;filetype == ‘mkd‘
"        call setline(1,"<head><meta charset=\"UTF-8\"></head>")
Else
call setline(1, "/*************************************************************************")
call append(line("."), "	> File Name: ".expand("%"))
call append(line(".")+1, "	> Author: ")
call append(line(".")+2, "	> Mail: ")
call append(line(".")+3, "	> Created Time: ".strftime("%c"))
call append(line(".")+4, " ************************************************************************/")
call append(line(".")+5, "")
Endif
if expand("%:e") == ‘cpp‘
call append(line(".")+6, "#include<iostream>")
call append(line(".")+7, "using namespace std;")
call append(line(".")+8, "")
Endif
if &amp;filetype == ‘c‘
call append(line(".")+6, "#include<stdio.h>")
call append(line(".")+7, "")
Endif
if expand("%:e") == ‘h‘
call append(line(".")+6, "#ifndef _".toupper(expand("%:r"))."_H")
call append(line(".")+7, "#define _".toupper(expand("%:r"))."_H")
call append(line(".")+8, "#endif")
Endif
if &amp;filetype == ‘java‘
call append(line(".")+6,"public class ".expand("%:r"))
call append(line(".")+7,"")
Endif
"Automatically navigate to the end of a new file
Endfunc
autocmd BufNewFile * normal G
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Keyboard commands
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:nmap <silent> <F9> <ESC>:Tlist<RETURN>
" shift tab pages
map <S-Left> :tabp<CR>
map <S-Right> :tabn<CR>
map! <C-Z> <Esc>zzi
map! <C-O> <C-Y>,
map <C-A> ggVG$"+y
map <F12> gg=G
map <C-w> <C-w>w
imap <C-k> <C-y>,
imap <C-t> <C-q><TAB>
imap <C-j> <ESC>
"Ctrl + C copy when selected
"map <C-v> "*pa
imap <C-v> <Esc>"*pa
imap <C-a> <Esc>^
imap <C-e> <Esc>$
vmap <C-c> "+y
Set mouse=v
"set clipboard=unnamed
"Go blank line"
nnoremap <F2> :g/^\s*$/d<CR>
"Compare files
nnoremap <C-F2> :vert diffsplit
"nnoremap <Leader>fu :CtrlPFunky<Cr>
"nnoremap <C-n> :CtrlPFunky<Cr>
"List current catalog files
map <F3> :NERDTreeToggle<CR>
imap <F3> <ESC> :NERDTreeToggle<CR>
"Open tree file directory
map <C-F3> \be
:autocmd BufRead,BufNewFile *.dot map <F5> :w<CR>:!dot -Tjpg -o %<.jpg % &amp;&amp; eog %<.jpg  <CR><CR> &amp;&amp; exec "redr!"
"C, C + + press F5 to compile and run
map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
Exec "W"
if &amp;filetype == ‘c‘
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &amp;filetype == ‘cpp‘
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &amp;filetype == ‘java‘
exec "!javac %"
exec "!time java %<"
elseif &amp;filetype == ‘sh‘
:!time bash %
elseif &amp;filetype == ‘python‘
exec "!time python2.7 %"
elseif &amp;filetype == ‘html‘
exec "!firefox % &amp;"
elseif &amp;filetype == ‘go‘
"        exec "!go build %<"
exec "!time go run %"
elseif &amp;filetype == ‘mkd‘
exec "!~/.vim/markdown.pl % > %.html &amp;"
exec "!firefox %.html &amp;"
Endif
Endfunc
"C, C + + debugging
map <F8> :call Rungdb()<CR>
func! Rungdb()
Exec "W"
exec "!g++ % -g -o %<"
exec "!gdb ./%<"
Endfunc
"Code format optimization
map <F6> :call FormartSrc()<CR><CR>
"Define formartsrc()
func FormartSrc()
Exec "W"
if &amp;filetype == ‘c‘
exec "!astyle --style=ansi -a --suffix=none %"
elseif &amp;filetype == ‘cpp‘ || &amp;filetype == ‘hpp‘
exec "r !astyle --style=ansi --one-line=keep-statements -a --suffix=none %> /dev/null 2>&amp;1"
elseif &amp;filetype == ‘perl‘
exec "!astyle --style=gnu --suffix=none %"
elseif &amp;filetype == ‘py‘||&amp;filetype == ‘python‘
exec "r !autopep8 -i --aggressive %"
elseif &amp;filetype == ‘java‘
exec "!astyle --style=java --suffix=none %"
elseif &amp;filetype == ‘jsp‘
exec "!astyle --style=gnu --suffix=none %"
elseif &amp;filetype == ‘xml‘
exec "!astyle --style=gnu --suffix=none %"
Else
exec "normal gg=G"
Return
Endif
Exec "E!%"
Endfunc
"End defining formartsrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" utility settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("autocmd")
autocmd BufReadPost *
\ if line("‘\"") > 0 &amp;&amp; line("‘\"") <= line("$") |
\   exe "normal g`\"" |
Endif
Endif
"Automatically open nerdtree when VIM is open and there is no file
autocmd vimenter * if !argc() | NERDTree | endif
"Automatically close when only nerdtree is left
autocmd bufenter * if (winnr("$") == 1 &amp;&amp; exists("b:NERDTreeType") &amp;&amp; b:NERDTreeType == "primary") | q | endif
"Set to load automatically when the file is changed
Set AUTOREAD
"Quickfix mode
autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
"Code completion
set completeopt=preview,menu
"Allow plug-ins
"filetype plugin on
"Share clipboard
"set clipboard+=unnamed
"Auto save
set autowrite
"Set ruler" opens the status bar ruler
"Set cursorline" highlights the current line
Set magic "set magic
Set guioptions - = t "hide toolbar
Set guioptions - = m "hide menu bar
""set foldcolumn=0
""set foldmethod=indent
""set foldlevel=3
"Instead of using VI's keyboard mode, VIM's own
set nocompatible
"Remove the prompt sound of input error
Set noeb
"When processing unsaved or read-only files, pop-up confirmation
Set confirm
"Disable temporary file generation
Set nobackup
set noswapfile
"Search ignores case
set ignorecase
set linespace=0
"Command line autocomplete in enhanced mode
Set wildmenu
"Enable backspace to handle indent, EOL, start, etc
set backspace=2
"Allow backspace and cursor keys to cross line boundaries
set whichwrap+=<,>,h,l
"You can use the mouse anywhere in the buffer (similar to double-click the mouse to locate in the workspace in office)
Set mouse=a
set selection=exclusive
set selectmode=mouse,key
"By using the: commands command, tell us which line of the file has been changed
Set report=0
"Display white space between divided windows for easy reading
Set fillchars = vert: \, STL: \, stlnc: "highlight matching brackets
set showmatch
"Time (in tenths of a second) to match bracket highlighting
set matchtime=1
"Keep 3 lines when the cursor moves to the top and bottom of the buffer
set scrolloff=3
"Provides automatic indentation for C programs
"Auto completion
"":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 to make up with intelligence
set completeopt=longest,menu
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Ctags setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Let tlist'sort'type = "name" "sort by name
Let TList? Use? Right? Window = 1 "show window on the right
Let TList? Compare? Format = 1 "compression method
Let TList \ \ exist \ \ onlywindow = 1 "if there is only one buffer, the kill window will also kill the 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 fold tree
"Let TList? Show? One? File = 1" does not display the tags of multiple files at the same time, but only the tags of the current file
"Set Tags
set tags=tags;
set autochdir
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Others
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Open taglist by default
let Tlist_Auto_Open=0
""""""""""""""""""""""""""""""
" Tag list (ctags)
""""""""""""""""""""""""""""""""
let Tlist_Ctags_Cmd = ‘/usr/local/bin/ctags‘
Let TList? Show? One? File = 1 "does not display the tags of multiple files at the same time, but only the tags of the current file
let Tlist_File_Fold_Auto_Close = 1
Let TList "exit" onlywindow = 1 "if the taglist window is the last window, exit VIM
Let TList? Use? Right? Window = 1 "display the taglist window in the right window
"General settings for minibufexpl plug-in
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
nmap tl :Tlist<cr>
"Python completion
let g:pydiction_location = ‘~/.vim/after/complete-dict‘
let g:pydiction_menu_height = 20
let Tlist_Ctags_Cmd=‘/usr/local/bin/ctags‘
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
set iskeyword+=.
set termencoding=utf-8
set encoding=utf8
set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030
autocmd FileType python set omnifunc=pythoncomplete#Complete
"set nocompatible               " be iMproved
"filetype off                   " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
"Required!
Bundle ‘gmarik/vundle‘
" My Bundles here:
"
" original repos on github
Bundle ‘tpope/vim-fugitive‘
Bundle ‘rstacruz/sparkup‘, {‘rtp‘: ‘vim/‘}
Bundle ‘Yggdroot/indentLine‘
let g:indentLine_char = ‘┊‘
"ndle ‘tpope/vim-rails.git‘
" vim-scripts repos
Bundle ‘L9‘
Bundle ‘FuzzyFinder‘
" non github repos
Bundle ‘https://github.com/wincent/command-t.git‘
Bundle ‘Auto-Pairs‘
Bundle ‘python-imports.vim‘
Bundle ‘CaptureClipboard‘
Bundle ‘ctrlp-modified.vim‘
Bundle ‘last_edit_marker.vim‘
Bundle ‘synmark.vim‘
"Bundle ‘Python-mode-klen‘
Bundle ‘SQLComplete.vim‘
Bundle ‘Javascript-OmniCompletion-with-YUI-and-j‘
"Bundle ‘JavaScript-Indent‘
"Bundle ‘Better-Javascript-Indentation‘
Bundle ‘jslint.vim‘
Bundle "pangloss/vim-javascript"
Bundle ‘Vim-Script-Updater‘
Bundle ‘ctrlp.vim‘
Bundle ‘tacahiroy/ctrlp-funky‘
Bundle ‘jsbeautify‘
Bundle ‘The-NERD-Commenter‘
"Django
Bundle ‘django_templates.vim‘
Bundle ‘Django-Projects‘
"Bundle ‘FredKSchott/CoVim‘
"Bundle ‘djangojump‘
"...
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
filetype plugin indent on     " required!
"
"Ctrlp settings
"
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.png,*.jpg,*.gif     " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe,*.pyc,*.png,*.jpg,*.gif  " Windows
let g:ctrlp_custom_ignore = ‘\v[\/]\.(git|hg|svn)$‘
let g:ctrlp_custom_ignore = ‘\v\.(exe|so|dll)$‘
let g:ctrlp_extensions = [‘funky‘]

let NERDTreeIgnore=[‘\.pyc‘]



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.