Skip to content

Instantly share code, notes, and snippets.

@shuLhan
Created June 9, 2010 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuLhan/430841 to your computer and use it in GitHub Desktop.
Save shuLhan/430841 to your computer and use it in GitHub Desktop.
My .vimrc
syntax enable
set number
set textwidth=77
set dir=~/Downloads/
set spellfile=~/.vim/spellfile.add
set nohidden
"" maximum number of tab opened
set tabpagemax=30
set fileformats=unix
" set spell
" set sessionoptions=sesdir,folds,help,tabpages,winsize,options,globals
"" enable filetype plugin
filetype plugin on
"set cindent
"set smartindent
"set autoindent
""
"" fold script by syntax
""
"set foldmethod=syntax
"set foldlevelstart=0
"set foldlevel=0
"let javaScript_fold=1 " JavaScript
"let perl_fold=1 " Perl
"let php_folding=1 " PHP
"let r_syntax_folding=1 " R
"let ruby_fold=1 " Ruby
"let sh_fold_enabled=1 " sh
"let vimsyn_folding='af' " Vim script
"let xml_syntax_folding=1 " XML
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
"" disable swap
"set nobackup
"set nowritebackup
"set noswapfile
"" highlight current tab.
highlight TabLineSel ctermbg=7 ctermfg=0
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
highlight SpecialKey ctermfg=9
match OverLength /\%80v.*/
"" highlight trailing white space
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
match ExtraWhitespace /\s\+$\| \+\ze\t/
"" show spaces for indenting
highlight NotTab ctermbg=darkgreen guibg=darkgreen
match NotTab /^\t*\zs \+/
"" ALT-right-arrow : switch to the next tab.
map  :tabnext<cr>
map!  <esc>:tabnext<cr><insert>
"" ALT-left-arrow : switch to the previous tab.
map  :tabprevious<cr>
map!  <esc>:tabprevious<cr><insert>
"" CTRL-\: move cursor or go to next window
map  :wincmd w<cr>
map!  <esc>:wincmd w<cr><insert>
"" CTRL-n: open a new tab
map  :tabedit
map!  <esc>:tabedit
"" CTRL-l : split window vertically.
map :vsplit
map! <esc>:vsplit
"" CTRL-s : save current buffer.
map  :w<cr>
map!  <esc>:w<cr>
"" allow inserting TAB on ESC mode.
map <Tab> <insert><tab><esc>
"" F1 : list all session.
map <F1> :SessionList<cr>
map! <F1> <esc>:SessionList<cr>
"" F12 : close session and exit vim.
map <F12> :wqa<cr>
map! <F12> <esc>:wqa<cr>
function MoveTabLeft()
let curtab = tabpagenr() - 2
if curtab >= 0
echo 'move to tab '.curtab
execute 'tabmove' curtab
endif
endfunction
function MoveTabRight()
let curtab = tabpagenr()
echo 'move to tab '.curtab
execute 'tabmove' curtab
endfunction
"" CTRL + page-up: move tab to the left
map [5;5~ <esc>:call MoveTabLeft()<cr>
map! [5;5~ <esc>:tabmove MoveTabLeft()<cr>
"" CTRL + page-down: move tab to the right
map [6;5~ <esc>:call MoveTabRight()<cr>
map! [6;5~ <esc>:tabmove MoveTabRight()<cr>
"" Highlight whitespace problems.
"" flags is '' to clear highlighting, or is a string to
"" specify what to highlight (one or more characters):
"" e whitespace at end of line
"" i spaces used for indenting
"" s spaces before a tab
"" t tabs not at start of line
function! ShowWhitespace(flags)
let bad = ''
let pat = []
for c in split(a:flags, '\zs')
if c == 'e'
call add(pat, '\s\+$')
elseif c == 'i'
call add(pat, '^\t*\zs \+')
elseif c == 's'
call add(pat, ' \+\ze\t')
elseif c == 't'
call add(pat, '[^\t]\zs\t\+')
else
let bad .= c
endif
endfor
if len(pat) > 0
let s = join(pat, '\|')
exec 'syntax match ExtraWhitespace "'.s.'" containedin=ALL'
else
syntax clear ExtraWhitespace
endif
if len(bad) > 0
echo 'ShowWhitespace ignored: '.bad
endif
endfunction
function! ToggleShowWhitespace()
if !exists('b:ws_show')
let b:ws_show = 0
endif
if !exists('b:ws_flags')
let b:ws_flags = 'eist' " default (which whitespace to show)
endif
let b:ws_show = !b:ws_show
if b:ws_show
call ShowWhitespace(b:ws_flags)
else
call ShowWhitespace('')
endif
endfunction
nnoremap <Leader>ws :call ToggleShowWhitespace()<CR>
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
"" set line number color
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
"
" NERDTree shorcut
"
map <F2> :NERDTreeToggle \| :silent NERDTreeMirror<CR>
"
" Custom tab and shiftwidth for specific file
"
autocmd FileType html
\ setlocal shiftwidth=4 |
\ setlocal tabstop=4
autocmd FileType jsp
\ setlocal shiftwidth=4 |
\ setlocal tabstop=4
autocmd FileType js
\ setlocal shiftwidth=4 |
\ setlocal tabstop=4
autocmd FileType javascript
\ setlocal shiftwidth=4 |
\ setlocal tabstop=4
autocmd FileType sql
\ setlocal shiftwidth=4 |
\ setlocal tabstop=4
autocmd FileType css
\ setlocal shiftwidth=4 |
\ setlocal tabstop=4
"" gvim
if has('gui_running')
colorscheme desert
set guifont=Terminus\ 8
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment