Skip to content

Instantly share code, notes, and snippets.

@xinali
Created May 6, 2019 09:05
Show Gist options
  • Save xinali/d1387be105426997b43f5e0c097d4fea to your computer and use it in GitHub Desktop.
Save xinali/d1387be105426997b43f5e0c097d4fea to your computer and use it in GitHub Desktop.
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
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