[Level 1] Useful vim environment settings.

My current vim settings are below.
You could get more sample in here.

set nu
set ic
:au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
set nosmartindent
set tabstop=4
set shiftwidth=4
set expandtab
set hlsearch
syntax on

" filetype indent plugin on
set background=dark
set modeline

" filetype indent on
" au FileType python setlocal tabstop=8 expandtab shiftwidth=4 softtabstop=4
" au FileType python setlocal ts=8 et sw=4 sts=4
set nobackup
set noswapfile
set showmode
set ruler
map j gj
map k gk<

" auto trim tailing spaces
autocmd BufWritePre *.py :%s/\s\+$//e

" folding
set foldenable 
set foldmethod=syntax 
set foldcolumn=0 
nnoremap @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')

" auto command
autocmd BufRead *.py nmap  :w !python %
autocmd FileType java map  :!javac "%:p" && java -cp "%:p:h" "%:t:r"
autocmd FileType c map  :!gcc --o "%:p:r.out "%:p" && "%:p:r.out"
autocmd FileType php noremap  :w!:!/usr/bin/php %
autocmd BufRead *.py nmap  :w !sh %

Wish this helps. regards, Stanley Huang

Comments

Popular posts from this blog

[Level 2] Shell Interactive With Zenity Episode 5 -- list

[Level 2] iif in Python