syntax enable
"set color theme
"colorscheme blackboard
set hidden " so if u want to go directly to a file, no tips show.
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" tip on github use username/repo
" tip on vim-script use repo
" other use git://git.user.com/comand-t.git
Plugin 'OmniCppComplete'
Plugin 'winmanager'
Plugin 'taglist.vim'
Plugin 'SuperTab'
Plugin 'scrooloose/nerdtree'
Plugin 'vim-scripts/c.vim'
Plugin 'grep.vim'
Plugin 'chazy/cscope_maps'
Plugin 'tpope/vim-surround'
Plugin 'vim-scripts/a.vim'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'neilagabriel/vim-geeknote'
Plugin 'Emmet.vim'
Plugin 'altercation/vim-colors-solarized'
" " The following are examples of different formats supported.
" " Keep Plugin commands between vundle#begin/end.
" " plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" " plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" " Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'
" " git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" " The sparkup vim script is in a subdirectory of this repo called vim.
" " Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" " Avoid a name conflict with L9
" Plugin 'user/L9', {'name': 'newL9'}
"
" " All of your Plugins must be added before the following line
call vundle#end() " required
set background=light
let g:solarized_termcolors=256
colorscheme solarized
filetype plugin indent on
"auto completed
"RUBY
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
"RUBY plugin
autocmd FileType ruby compiler ruby
"autocmd vimenter * if !argc() | NERDTree | endif
"autocmd VimEnter * NER
" 设定文件浏览器目录为当前目录
set bsdir=buffer
" 设置编码
set enc=utf-8
" 设置文件编码
set fenc=utf-8
" 设置文件编码检测类型及支持格式
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
"显示行号
set number
"忽略大小写查找
set ic
" tab宽度
set tabstop=2
set expandtab
retab
set cindent shiftwidth=2
set autoindent shiftwidth=2
set shiftround
" set 折叠
set foldmethod=indent
" 打开文件默认不折叠
set foldlevelstart=99
let g:vim_markdown_folding_disabled = 1
"set my leader
let mapleader=","
let g:mapleader=","
"tabs
map <leader>tn :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
"打开vimrc 文件 edit vimrc
:nnoremap <leader>ev :vsplit $MYVIMRC<cr>
"source file, the file excute as VimScript
:nnoremap <leader>sv :source $MYVIMRC<cr>
" 映射NERDTree插件
":map <leader>n :NERDTree<CR>
"let loaded_nerd_tree = 1
let NERDTreeQuitOnOpen = 0
let NERDChristmasTree=1
let g:NERDTreeWinSize = 18
map <leader>f :NERDTreeToggle<CR>
"switch window
:map <leader>w <C-W>w
" 把 CTRL-S 映射为 保存,因为这个操作做得太习惯了
imap <C-S> <C-C>:w<CR>
"set zen coding
let g:user_zen_settings = {
'php' : {
'extends' : 'html',
'filters' : 'c',
},
'xml' : {
'extends' : 'html',
},
'haml' : {
'extends' : 'html',
},
'erb' : {
'extends' : 'html',
},
}
"set CtrlP
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 2
"use in edit
imap <C-A> <C-C><c-p>
"use in none edit
:map <leader>t <c-p>
:map <leader>b :CtrlPBuffer<CR>
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.jpg,*.png,*.gif,*.jpeg,.DS_Store " MacOSX/Linux
let g:ctrlp_custom_ignore = '.git$|.hg$|.svn$'
" move lines up or down (command - D)
nmap <D-j> mz:m+<cr>`z
nmap <D-k> mz:m-2<cr>`z
vmap <D-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <D-k> :m'<-2<cr>`>my`<mzgv`yo`z
" Tab move lines left or right (c-Ctrl,s-Shift)
nmap <c-tab> v>
nmap <s-tab> v<
vmap <c-tab> >gv
vmap <s-tab> <gv
" tab navigation like zsh
:nmap <D-1> :tabprevious<CR>
:map <D-1> :tabprevious<CR>
imap <D-1> <Esc>:tabprevious<CR>i
:nmap <D-2> :tabnext<CR>
:map <D-2> :tabnext<CR>
imap <D-2> <Esc>:tabnext<CR>i
"scss,sass
au BufRead,BufNewFile *.scss set filetype=scss
au BufRead,BufNewFile *.sass set filetype=scss
"coffee script
au BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable
au BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
hi link coffeeSpaceError NONE
hi link coffeeSemicolonError NONE
hi link coffeeReservedError NONE
map <leader>cf :CoffeeCompile watch vert<cr>
"let skim use slim syntax
au BufRead,BufNewFile *.skim set filetype=slim
"ctags
set tags+=~/gitdb/rails/tags
"auto completed
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.ruby = '[^. * ].w*|hw*::'
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
" code search
let g:ackprg = 'ag --nogroup --nocolor --column'
"set powerline
set laststatus=2
"set guifont=Powerline
"set font=Source Code Pro:h15
set nocompatible
set t_Co=256
let g:Powerline_cache_enabled = 1
"minitest
set completefunc=syntaxcomplete#Complete
"process past
set pastetoggle=<F2>
nnoremap <F2> :set invpaste paste?<CR>
imap <F2> <C-O>:set invpaste paste?<CR>
set pastetoggle=<F2>
set mouse=a
""""""""""""""""""""""""""""""
" Tag list (ctags)
""""""""""""""""""""""""""""""
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Show_Menu = 1
let Tlist_Auto_Open = 1
"let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口
"if(executable("cscope") && has("cscope") )
" silent! execute "!find . -name "*.h" -o -name "*.c" -o -name "*.cpp" -o -name "*.m" -o -name "*.mm" -o -name "*.java" -o -name "*.py" > cscope.files"
"endif
"silent! execute "!cscope -b"
"if filereadable("cscope.out")
" execute "cs a cscope.out"
"endif
"save the tag when write the file
function UpdateCtags()
let curdir=getcwd()
while !filereadable("./tags")
cd ..
if getcwd() == "/"
break
endif
endwhile
if filewritable("./tags")
:!ctags -R
endif
execute ":cd " . curdir
endfunction
function UpdateCStags()
let curdir=getcwd()
while !filereadable("./cscope.out")
cd ..
if getcwd() == "/"
break
endif
endwhile
if filewritable("./cscope.out")
:!cscope -Rbq
execute ":cscope reset"
endif
execute ":cd " . curdir
endfunction
nnoremap <leader>ut :call UpdateCtags()<CR>
nnoremap <leader>us :call UpdateCStags()<CR>
nmap w= :resize +3<CR>
nmap w- :resize -3<CR>
nmap w, :vertical resize -3<CR>
nmap w. :vertical resize +3<CR>