add script of wifif config for raspberry pi
[dotfiles.git] / vim / vimrc
index 04735e9..dafbea7 100644 (file)
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -13,7 +13,8 @@ Bundle 'vim-scripts/FuzzyFinder'
 Bundle 'vim-scripts/L9'
 Bundle 'Valloric/YouCompleteMe'
 Bundle 'octol/vim-cpp-enhanced-highlight'
-Bundle 'bling/vim-airline'
+Bundle 'vim-airline/vim-airline'
+Bundle 'vim-airline/vim-airline-themes'
 Bundle 'payneseu/nerdtree'
 Bundle 'Townk/vim-autoclose'
 Bundle 'majutsushi/tagbar'
@@ -34,6 +35,11 @@ Bundle 'tpope/vim-markdown'
 "Bundle 'vim-scripts/genutils'
 "Bundle 'vim-scripts/Marks-Browser'
 Bundle 'MattesGroeger/vim-bookmarks'
+"Bundle 'tpope/vim-repeat'
+"Bundle 'kien/ctrlp.vim'
+"disable since some conflicting mapping
+Bundle 'vim-latex/vim-latex'
+Plugin 'vimperator/vimperator.vim'
 
 call vundle#end()
 filetype plugin indent on
@@ -41,6 +47,7 @@ filetype plugin indent on
 " }}}
 " Basic options ----------------------------------------------------------- {{{
 set number
+set relativenumber
 set tabstop=4
 set softtabstop=4
 set shiftwidth=4
@@ -75,7 +82,9 @@ set hlsearch
 set autoindent
 set confirm
 set nostartofline   " don't jump to first character when paging
-set nowrap
+set wrap
+set expandtab
+set backspace=indent,eol,start
 "set textwidth, formatoptions for chinese
 set formatoptions+=m
 set colorcolumn=+1
@@ -86,7 +95,7 @@ if has("gui_running")
        set macmeta  "" Macvim only
        colorscheme molokai
        set guioptions+=c
-       set guifont=Sauce\ Code\ Powerline\ Light:h11
+       set guifont=Source\ Code\ Pro\ Light:h11
        highlight Cursor guifg=white guibg=green
        set guicursor=a:blinkon0
        set guioptions=eac
@@ -111,6 +120,8 @@ endif
 " Mappings ---------------------------------------------------------------- {{{
 let mapleader = ";"
 map Q gq
+nnoremap Q <Nop>
+nnoremap gq <Nop>
 " Normal mode ------------------------------------------------------------- {{{
 nnoremap Y     y$
 nnoremap ' `
@@ -123,7 +134,7 @@ nmap <Leader>q      :q<CR>
 nmap <Leader>e :e<Space>
 nmap <Leader>W :w !sudo tee %<CR>
 nmap <Leader>h :vertical help<Space>
-nmap <Leader>t :tabedit<Space>
+nmap <Leader>t :tabedit %<Space>
 "nmap <Leader>x        :x<CR>
 
 " windows 
@@ -143,7 +154,7 @@ nmap =      <C-w>=
 nnoremap <C-D> <C-D>zz
 nnoremap <C-U> <C-U>zz
 
-nnoremap <SPACE>       <C-F>
+"nnoremap <SPACE>      <C-F>
 nnoremap <S-SPACE>     <C-B>
 nnoremap <BS>  <C-B>
 nnoremap <A-n> gt
@@ -152,18 +163,21 @@ nnoremap <A-p>    gT
 " map <A-TAB> Alt+TAB  
 "noremap <A-S-TAB> "input C-V then input key sequence to
 "http://vim.wikia.com/wiki/Make_Shift-Tab_work
-nnoremap <ESC><TAB> :bn<CR>
-nnoremap \e\19 :bp<CR>
+"nnoremap <ESC><TAB> :bn<CR>
+nnoremap <ESC><TAB> :tabnext<CR>
+"nnoremap \e\19 :bp<CR>
+nnoremap \e\19 :tabprevious<CR>
 "nmap <A-S-TAB>        :bp<CR>
 "nmap <A-SPACE>        :b#<CR>
 "nmap <Leader>d        :bd<CR>
 "" keymappig for register operations
-nnoremap <Leader>r     :registers<CR>
+""TODO check if this already mapping
+"nnoremap <Leader>r    :registers<CR>
 "noremap <Leader>x     :<C-p>
 nnoremap <Leader>a :
 
 nmap <Leader>p "*p
-
+" also works :r !pbpaste<CR>
 
 nmap <A-=> :resize<CR>:vertical resize<CR>
 nmap \e= :resize<CR>:vertical resize<CR>
@@ -176,6 +190,9 @@ nnoremap zR zRzz
 nnoremap zr    zrzz
 nnoremap zn znzz
 
+nnoremap zj zjzz
+nnoremap zh zhzz
+
 noremap <Leader>z      zmzvzz
 nmap \\ :nohlsearch<CR>
 " }}}
@@ -185,8 +202,9 @@ inoremap <C-U> <C-G>u<C-U>
 inoremap <C-a> <Home>
 inoremap <C-e> <End>
 inoremap <C-D> <Del>
-inoremap <C-b> <S-Left>
-inoremap <C-f> <S-Right>
+inoremap <C-b> <Left>
+inoremap <C-f> <Right>
+inoremap <C-/> <Esc>ui
 imap <A-d>     <S-Right><C-w>
 " }}}
 " Command mode ------------------------------------------------------- {{{
@@ -220,6 +238,14 @@ vmap <C-k> {
 vmap <C-j>     }       
 "vmap <Leader>y        "*y
 vmap Y "*y
+"
+"vmap <C-Y>  "qy
+"vmap <C-P>  "qp
+vnoremap    Y   "*y
+vnoremap    <Leader>p  "*p
+"search for visually selectecd text
+vnoremap // y/<C-R>"<CR>
+vnoremap <Leader>a  :
 " }}}
 " }}}
 " Plugins Configuration --------------------------------------------------- {{{
@@ -234,18 +260,18 @@ nnoremap <silent> sj     :FufBuffer<CR>
 nnoremap <silent> sk     :FufFileWithCurrentBufferDir<CR>
 nnoremap <silent> sK     :FufFileWithFullCwd<CR>
 nnoremap <silent> s<C-k> :FufFile<CR>
-nnoremap <silent> sl     :FufCoverageFileChange<CR>
-nnoremap <silent> sL     :FufCoverageFileChange<CR>
-nnoremap <silent> s<C-l> :FufCoverageFileRegister<CR>
+"nnoremap <silent> sl     :FufCoverageFileChange<CR>
+"nnoremap <silent> sL     :FufCoverageFileChange<CR>
+"nnoremap <silent> s<C-l> :FufCoverageFileRegister<CR>
 nnoremap <silent> sd     :FufDirWithCurrentBufferDir<CR>
 nnoremap <silent> sD     :FufDirWithFullCwd<CR>
 nnoremap <silent> s<C-d> :FufDir<CR>
 nnoremap <silent> sn     :FufMruFile<CR>
 nnoremap <silent> sN     :FufMruFileInCwd<CR>
 nnoremap <silent> sm     :FufMruCmd<CR>
-nnoremap <silent> su     :FufBookmarkFile<CR>
+"nnoremap <silent> su     :FufBookmarkFile<CR>
 nnoremap <silent> s<C-u> :FufBookmarkFileAdd<CR>
-vnoremap <silent> s<C-u> :FufBookmarkFileAddAsSelectedText<CR>
+"vnoremap <silent> s<C-u> :FufBookmarkFileAddAsSelectedText<CR>
 nnoremap <silent> si     :FufBookmarkDir<CR>
 nnoremap <silent> s<C-i> :FufBookmarkDirAdd<CR>
 nnoremap <silent> sT     :FufTag<CR>
@@ -253,29 +279,39 @@ nnoremap <silent> st     :FufTag!<CR>
 nnoremap <silent> s<C-]> :FufTagWithCursorWord!<CR>
 nnoremap <silent> s,     :FufBufferTag<CR>
 nnoremap <silent> s<     :FufBufferTag!<CR>
-vnoremap <silent> s,     :FufBufferTagWithSelectedText!<CR>
-vnoremap <silent> s<     :FufBufferTagWithSelectedText<CR>
+"vnoremap <silent> s,     :FufBufferTagWithSelectedText!<CR>
+"vnoremap <silent> s<     :FufBufferTagWithSelectedText<CR>
 nnoremap <silent> s}     :FufBufferTagWithCursorWord!<CR>
+nnoremap <silent> sl     :FufBufferTagAll<CR>
 "nnoremap <silent> s.     :FufBufferTagAll<CR>
-"nnoremap <silent> s>     :FufBufferTagAll!<CR>
+nnoremap <silent> s>     :FufBufferTagAll!<CR>
 "vnoremap <silent> s.     :FufBufferTagAllWithSelectedText!<CR>
 "vnoremap <silent> s>     :FufBufferTagAllWithSelectedText<CR>
 "nnoremap <silent> s]     :FufBufferTagAllWithCursorWord!<CR>
 nnoremap <silent> sG     :FufTaggedFile<CR>
 nnoremap <silent> sg     :FufTaggedFile!<CR>
-nnoremap <silent> so     :FufJumpList<CR>
-nnoremap <silent> sp     :FufChangeList<CR>
-nnoremap <silent> sq     :FufQuickfix<CR>
-nnoremap <silent> sy     :FufLine<CR>
+"nnoremap <silent> so     :FufJumpList<CR>
+"nnoremap <silent> sp     :FufChangeList<CR>
+"nnoremap <silent> sq     :FufQuickfix<CR>
+"nnoremap <silent> sy     :FufLine<CR>
 "  nnoremap <silent> sh     :FufHelp<CR>
-nnoremap <silent> se     :FufEditDataFile<CR>
+"nnoremap <silent> se     :FufEditDataFile<CR>
 nnoremap <silent> sr     :FufRenewCache<CR>
 " }}}
 " YouCompleteMe ----------------------------------------------------------- {{{
 "syntax on, must before the YCM,
 
-let g:ycm_collect_identifiers_from_tags_files = 1
+" Load YouCompleteMe only on OSX
+if !has("osx")
+    let g:loaded_youcompleteme = 1
+endif
+
+"let g:ycm_collect_identifiers_from_tags_files = 1
 let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
+" this is fix youcompleteme python error
+"http://www.cnblogs.com/clivelee/p/4266559.html
+"https://github.com/Valloric/YouCompleteMe/issues/18
+"let g:ycm_path_to_python_interpreter= '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python'
 let g:ycm_auto_trigger = 1
 let g:ycm_seed_identifiers_with_syntax = 1
 let g:ycm_show_diagnostics_ui = 0
@@ -312,7 +348,8 @@ let g:ycm_key_detailed_diagnostics = ''
        let g:airline_right_sep = ''
        let g:airline_right_alt_sep = ''
 
-       let g:airline#extensions#tabline#show_buffers = 1
+"      let g:airline#extensions#tabline#show_buffers = 1
+       let g:airline#extensions#tabline#show_buffers = 0
        let g:airline#extensions#tabline#enabled = 1
        let g:airline#extensions#tabline#left_sep = ''
        let g:airline#extensions#tabline#left_alt_sep =''
@@ -349,6 +386,8 @@ endfunction
 "endif
 " }}}
 " NerdTree ---------------------------------------------------------------- {{{
+" Fix keymapping conflict
+nmap <unique> <Leader>, <Plug>MarkClear
 nmap <Leader>n :NERDTreeToggle<CR>
 nmap <Leader>N :NERDTreeFind<CR>
 " }}}
@@ -401,8 +440,8 @@ endif
 " }}}
 " Marks ------------------------------------------------------------------- {{{
 nmap  \h <Plug>MarkSet
-nmap  * <Plug>MarkSearchNext
-nmap  # <Plug>MarkSearchPrev
+"nmap  * <Plug>MarkSearchNext
+"nmap  # <Plug>MarkSearchPrev
 " }}}
 " Gundo ------------------------------------------------------------------- {{{
 "    nnoremap <F5> :GundoToggle<CR>
@@ -432,7 +471,38 @@ let g:bookmark_auto_close = 1
 "  nmap ,c <Plug>BookmarkClear
 "  nmap ,x <Plug>BookmarkClearAll
 " }}}
-
+" EasyMotion -------------------------------------------------------------- {{{
+map en <Plug>(easymotion-sn)
+map ej <Plug>(easymotion-j)
+map ek <Plug>(easymotion-k)
+map eb <Plug>(easymotion-b)
+map ew <Plug>(easymotion-w)
+map ee <Plug>(easymotion-w)
+map el <Plug>(easymotion-lineforward)
+map eh <Plug>(easymotion-linebackward)
+
+"map <SPACE>n <Plug>(easymotion-sn)
+"map <SPACE>j <Plug>(easymotion-j)
+"map <SPACE>k <Plug>(easymotion-k)
+"map <SPACE>b <Plug>(easymotion-b)
+"map <SPACE>w <Plug>(easymotion-w)
+"map <SPACE>e <Plug>(easymotion-w)
+"map <SPACE>l <Plug>(easymotion-lineforward)
+"map <SPACE>h <Plug>(easymotion-linebackward)
+
+"" }}}
+" vim-latex --------------------------------------------------------------- {{{
+"set grepprg=grep\ -nH\ $*
+"let g:tex_flavor='latex'
+"set iskeyword+=:
+"autocmd BufEnter *.tex set sw=2
+"disable default mapping 
+imap #$ <Plug>IMAP_JumpForward
+nmap #$ <Plug>IMAP_JumpForward
+vmap #$ <Plug>IMAP_JumpForward
+vmap #$ <Plug>IMAP_DeleteAndJumpForward
+let g:Imap_FreezeImap=1
+" }}}
 " }}}
 " FileType ---------------------------------------------------------------- {{{
 autocmd BufNewFile,BufRead *.log set filetype=logecc
@@ -455,8 +525,10 @@ autocmd FileType qf nnoremap <buffer> <silent> q :q<CR> | setlocal nowrap | setl
 autocmd FileType help nnoremap <buffer> <silent> q :q<CR> | vertical resize 85;
 autocmd FileType c,cpp setlocal foldmethod=syntax |
     \ let b:AutoClosePairs = AutoClose#DefaultPairsModified("\"", "{}") |
-       \ inoremap <buffer> { {<CR>}<ESC>kA<CR>
-autocmd FileType python setlocal foldmethod=indent
+       \ inoremap <buffer> { {<CR>}<ESC>kA<CR>|
+    \ nnoremap <buffer> <silent> <C-]> :let word=expand("<cword>")<CR>:wincmd o<cr>:vsp<CR>:exec("tag ". word)<cr>zzzr:wincmd w<cr>
+autocmd FileType python setlocal foldmethod=indent |
+    \ set list
 
 autocmd FileType xml setlocal foldmethod=syntax |
        \ let g:xml_syntax_folding=1
@@ -464,6 +536,10 @@ autocmd FileType vim setlocal foldmethod=marker |
        \ setlocal formatoptions-=c formatoptions-=r formatoptions-=o |
     \ let b:AutoClosePairs = AutoClose#DefaultPairsModified("", "{} \"")
 
+autocmd FileType perl setlocal foldmethod=syntax |
+    \ let b:AutoClosePairs = AutoClose#DefaultPairsModified("\"", "{}") |
+       \ inoremap <buffer> {<CR> {<CR>}<ESC>kA<CR>
+
 autocmd Filetype markdown setlocal textwidth=80
 
 autocmd CmdwinEnter * map <buffer> q :q<CR>
@@ -564,7 +640,7 @@ nmap <silent> \q :call ToggleList("Quickfix List", 'c')<CR>
 "endif
 function! DiffToggle()
        if(&diff)
-               diffoff | wincmd h | wincmd o
+               diffoff | wincmd l | :q
        else
                exec ":VCSVimDiff" | wincmd h
        endif
@@ -576,7 +652,7 @@ nnoremap \d :call DiffToggle()<CR>
 " }}}
 
 "nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
-nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR>
+nnoremap <silent> <cr> @=(foldlevel('.')?'za':"\<Space>")<CR>
 "noremap <Leader>d     @=(&diff)?':diffoff':":VCSVimDiff"<CR><CR>
 
 " https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc
@@ -607,8 +683,29 @@ iabbrev            "}   " }}}
 " m
 nnoremap B ^
 nnoremap E $
-nnoremap <C-N> :cn<CR>
-nnoremap <C-P> :cp<CR>
+nnoremap <C-N> :cn<CR>zzzv
+nnoremap <C-P> :cp<CR>zzzv
 "http://dougblack.io/words/a-good-vimrc.html
 "nnoremap gV `[v`]
 
+"nnoremap <silent> <C-]> :let word=expand("<cword>")<CR>:vsp<CR>:wincmd w<cr>:exec("tag ". word)<cr>
+"nnoremap <silent> <C-]> :let word=expand("<cword>")<CR>:wincmd o<cr>:vsp<CR>:exec("tag ". word)<cr>zz:wincmd w<cr>
+" command in normal mode, and visual mode
+" yiw  = viwy
+" diw  = viwd
+" gn   select search and in visual mode
+" confirm when using :q to quit the last tab page,
+"Alias q if\ winnr('$')>1||tabpagenr('$')>1||confirm('Really\ quit?',\ "&OK\\n&Cancel")==1|quit|endif
+
+
+
+" color of current line
+"let s:marklist = ''
+nnoremap <Leader>m  :marks abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<CR>:normal '
+
+"let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir', 'rtscript',
+"                          \ 'undo', 'line', 'changes', 'mixed', 'bookmarkdir']
+
+
+"" TODO: 
+""