Skip to content

Instantly share code, notes, and snippets.

@chao-he
Created February 26, 2014 02:20
Show Gist options
  • Save chao-he/9222229 to your computer and use it in GitHub Desktop.
Save chao-he/9222229 to your computer and use it in GitHub Desktop.
a basic vim config
" how many lines of history VIM has to remember
set history=100
" Enable filetype plugin
filetype plugin on
filetype indent on
" Set to auto read when file changed outside
set autoread
" Enable mouse if we heve
"if has("mouse")
" set mouse=a
"endif
" With a map leader it's possible to do extra key
" combinations like <leader>w saves the current file
let mapleader=","
let g:mapleader=","
" when vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vimrc
set so=7 "7 lines to cursors when moving vertical
set wildmenu "turn on wild menu
set ruler "always show current position
set cmdheight=1 "the commandbar height
set hid "change buffer - without saving
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase
set smartcase
set hlsearch
set incsearch
set noerrorbells
set novisualbell
set t_vb=
set number
set encoding=utf-8
set fileencoding=utf-8
"set fileencodings=ucs-bom,gbk,utf-8,cp936
"lang zh_CN.utf-8
set foldmethod=marker
set foldenable
syntax enable
colorscheme desert
set background=dark
set ffs=unix,dos,mac
set nobackup
set nowb
set noswapfile
set expandtab
set smarttab
set shiftwidth=4
set tabstop=4
"set lbr
set tw=2000
set pastetoggle=<F10>
set autoindent
set smartindent
"set wrap
" Using system clipboard without "*
set clipboard=unnamed
" always show status line
set laststatus=2
set statusline=\ %{HasPaste()}%F\ Line:%l/%L\ Col:%c\ %m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h
function! CurDir()
let curdir = substitute(getcwd(), '/home/whitelist/', "~/", "g")
return curdir
endfunction
function! HasPaste()
if &paste
return 'PASTE '
else
return ''
endif
endfunction
" Abbrevs and key mapping
iab idate <c-r>=strftime("%Y-%m-%d %H:%M:%S")<cr>
iab iauthor <c-r>="Chao He <[email protected]>"<cr>
noremap ww <ESC>:w<CR>
map 0 ^
map 9 $
nmap <leader><leader>e :NERDTreeToggle<cr><cr>
nmap <leader><leader>t :TagListToggle<cr><cr>
map <Leader><leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'y
map <space> /
map <M-space> ?
map <silent> <leader><cr> :noh<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment