Skip to content

Instantly share code, notes, and snippets.

@xinali
Last active November 7, 2018 12:12
Show Gist options
  • Save xinali/e5ba9e33d2ab942d35dda7a0bfa98029 to your computer and use it in GitHub Desktop.
Save xinali/e5ba9e33d2ab942d35dda7a0bfa98029 to your computer and use it in GitHub Desktop.
vim配置文件
set nocompatible
set encoding=utf-8
set lines=40
set columns=100
" set font in linux set guifont=Monospace\ 14
" set font in windows
set guifont=Consolas:h14
" for gvim
set guioptions-=T
set guioptions-=m
colorscheme murphy
" c coding indent, turn off when use python
" set cindent
syntax on
set nu
set autoindent
set cindent
set shiftwidth=4
set tabstop=4
set softtabstop=4
set nobackup
set showcmd
set showmode
set showmatch
filetype on
filetype plugin on
filetype indent on
" insert # as comment
map <C-I> I# <ESC>
map <silent> <F5> :call Compile()<CR>
function! Compile()
exec "w"
if &filetype == "python"
exec "!python2.7 %"
endif
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!g++ % -o test"
exec "!./test"
elseif &filetype == 'cpp'
exec "!g++ % -o test"
exec "!./test"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
elseif &filetype == 'sh'
exec "!bash %"
endif
endfunc
" Python default settings
" autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType ruby set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai
autocmd BufRead,BufNew *.md,*.mkd,*.markdown set filetype=markdown.mkd
" when save python file, then delete redundant space
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
" when vimrc changed, thend auto load with windows
"autocmd! bufwritepost _vimrc source %
" when vimrc changed, thend auto load with linux
autocmd! bufwritepost .vimrc source %
" history account
set history=2000
set clipboard=unnamed
set laststatus=2
set statusline=
set statusline+=%7*\[%n] "buffernr
set statusline+=%1*\ %<%F\ "File+path
set statusline+=%2*\ %y\ "FileType
set statusline+=%3*\ %{''.(&fenc!=''?&fenc:&enc).''} "Encoding
set statusline+=%3*\ %{(&bomb?\",BOM\":\"\")}\ "Encoding2
set statusline+=%4*\ %{&ff}\ "FileFormat
set statusline+=%5*\ %{&spelllang}\%{HighlightSearch()}\ "Spellanguage & Highlight on?
set statusline+=%8*\ %=\ row:%l/%L\ (%03p%%)\ "Rownumber/total (%)
set statusline+=%9*\ col:%03c\ "Colnr
set statusline+=%0*\ \ %m%r%w\ %P\ \ "Modified? Readonly?
function! HighlightSearch()
if &hls
return 'H'
else
return ''
endif
endfunction
set nocompatible
set encoding=utf-8
"set lines=40 columns=100
" set font in linux set guifont=Monospace\ 14
" set font in windows
" set guifont=Consolas:h14
" for gvim
" set guioptions-=T set guioptions-=m
" colorscheme murphy
" c coding indent, turn off when use python
" set cindent
syntax on
set nu
set autoindent
set cindent
set shiftwidth=4
set tabstop=4
set softtabstop=4
set nobackup
set showcmd
set showmode
set showmatch
filetype on
filetype plugin on
filetype indent on
" insert # as comment
map <C-I> I# <ESC>
map <silent> <F5> :call Compile()<CR>
function! Compile()
exec "w"
if &filetype == "python"
exec "!python2.7 %"
endif
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!g++ % -o test"
exec "!./test"
elseif &filetype == 'cpp'
exec "!g++ % -o test"
exec "!./test"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
elseif &filetype == 'sh'
exec "!bash %"
endif
endfunc
" Python default settings
" autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai
autocmd FileType ruby set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai
autocmd BufRead,BufNew *.md,*.mkd,*.markdown set filetype=markdown.mkd
" when save python file, then delete redundant space
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
" when vimrc changed, thend auto load with windows
"autocmd! bufwritepost _vimrc source %
" when vimrc changed, thend auto load with linux
autocmd! bufwritepost .vimrc source %
" history account
set history=2000
call plug#begin('~/.vim/plugged')
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" NERD Commenter
Plug 'scrooloose/nerdcommenter'
Plug 'altercation/vim-colors-solarized'
" Add plugins to &runtimepath
call plug#end()
" NERDTree config
map <F2> :NERDTreeToggle<CR>
"map :silent! NERDTreeToggle
"autocmd vimEnter * NERDTree
" NERD Commenter config
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/*','right': '*/' } }
" let g:NERDCustomDelimiters = { 'python': { 'left': '/*','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" nerdcommenter config
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
let mapleader=","
autocmd FileType python set expandtab
set clipboard=unnamed
set laststatus=2
set statusline=
set statusline+=%7*\[%n] "buffernr
set statusline+=%1*\ %<%F\ "File+path
set statusline+=%2*\ %y\ "FileType
set statusline+=%3*\ %{''.(&fenc!=''?&fenc:&enc).''} "Encoding
set statusline+=%3*\ %{(&bomb?\",BOM\":\"\")}\ "Encoding2
set statusline+=%4*\ %{&ff}\ "FileFormat
set statusline+=%5*\ %{&spelllang}\%{HighlightSearch()}\ "Spellanguage & Highlight on?
set statusline+=%8*\ %=\ row:%l/%L\ (%03p%%)\ "Rownumber/total (%)
set statusline+=%9*\ col:%03c\ "Colnr
set statusline+=%0*\ \ %m%r%w\ %P\ \ "Modified? Readonly?
function! HighlightSearch()
if &hls
return 'H'
else
return ''
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment