332 lines
8.7 KiB
VimL
332 lines
8.7 KiB
VimL
nnoremap <SPACE> <Nop>
|
|
let g:mapleader = ' '
|
|
|
|
" Quickly insert an empty new line without entering insert mode
|
|
nnoremap <Leader>o o<Esc>
|
|
nnoremap <Leader>O O<Esc>
|
|
|
|
" workman
|
|
noremap <C-K> <C-O>
|
|
noremap <Tab> <C-I>
|
|
|
|
noremap e j
|
|
noremap o k
|
|
noremap n h
|
|
noremap i l
|
|
noremap k n
|
|
noremap h e
|
|
noremap l o
|
|
noremap f u
|
|
noremap u i
|
|
|
|
noremap E J
|
|
noremap O K
|
|
noremap N H
|
|
noremap I L
|
|
noremap K N
|
|
noremap H E
|
|
noremap L O
|
|
noremap F U
|
|
noremap U I
|
|
|
|
noremap ge gj
|
|
noremap go gk
|
|
noremap gn gh
|
|
noremap gl go
|
|
noremap gk gn
|
|
noremap gh ge
|
|
|
|
noremap gE gJ
|
|
noremap gN gH
|
|
noremap gK gN
|
|
noremap gH gE
|
|
noremap gL gO
|
|
|
|
nnoremap <silent> <c-w>e :wincmd j<cr>
|
|
nnoremap <silent> <c-w>o :wincmd k<cr>
|
|
nnoremap <silent> <c-w>n :wincmd h<cr>
|
|
nnoremap <silent> <c-w>i :wincmd l<cr>
|
|
nnoremap <silent> <c-w>k :wincmd n<cr>
|
|
nnoremap <silent> <c-w>l :wincmd o<cr>
|
|
|
|
vnoremap <c-n> B
|
|
vnoremap <c-i> W
|
|
nnoremap <c-n> B
|
|
nnoremap <c-i> W
|
|
|
|
vnoremap <A-n> b
|
|
vnoremap <A-i> w
|
|
nnoremap <A-n> b
|
|
nnoremap <A-i> w
|
|
" nnoremap <c-n>i e
|
|
|
|
" get control-j back, so switch it with ctrl-n at qwerty position of j
|
|
" imap <c-n> <cr>
|
|
" cmap <c-n> <cr>
|
|
inoremap <c-j> <c-n>
|
|
cnoremap <c-j> <c-n>
|
|
|
|
" half scroll up and down
|
|
noremap <C-A-p> <C-u>
|
|
noremap <C-A-u> <C-d>
|
|
map <C-d> <Nop>
|
|
|
|
|
|
" jump word in visual mode -- TODO
|
|
|
|
" In insert or command mode, move normally by using Ctrl
|
|
inoremap <C-n> <Left>
|
|
inoremap <C-e> <Down>
|
|
inoremap <C-o> <Up>
|
|
inoremap <C-i> <Right>
|
|
cnoremap <C-n> <Left>
|
|
cnoremap <C-e> <Down>
|
|
cnoremap <C-o> <Up>
|
|
cnoremap <C-i> <Right>
|
|
|
|
inoremap <C-A-n> <C-Left>
|
|
inoremap <C-A-i> <C-Right>
|
|
|
|
inoremap <C-A-e> <Esc>:+3<CR>i
|
|
inoremap <C-A-o> <Esc>:-3<CR>i
|
|
|
|
" easy config
|
|
nmap <S-F9> :e $HOME/.vimrc<CR>
|
|
nmap <S-F10> :so $HOME/.vimrc<CR>
|
|
|
|
" Force saving files that require root permission
|
|
command! SUDOwrite :execute 'w !sudo tee > /dev/null %' | edit!
|
|
|
|
" TODO: C-S-o etc does not work
|
|
" Bubble single lines
|
|
nmap <silent> <C-S-Up> :m-2<CR>==
|
|
nmap <silent> <C-S-o> :m-2<CR>==
|
|
nmap <silent> <C-S-Down> :m+<CR>==
|
|
nmap <silent> <C-S-e> :m+<CR>==
|
|
imap <silent> <C-S-Up> <Esc>:m-2<CR>==gi
|
|
imap <silent> <C-S-o> <Esc>:m-2<CR>==gi
|
|
imap <silent> <C-S-Down> <Esc>:m+<CR>==gi
|
|
imap <silent> <C-S-e> <Esc>:m+<CR>==gi
|
|
|
|
" Bubble multiple lines
|
|
vmap <silent> <C-S-Up> :m-2<CR>gv=gv
|
|
vmap <silent> <C-S-o> :m-2<CR>gv=gv
|
|
vmap <silent> <C-S-Down> :m'>+<CR>gv=gv
|
|
vmap <silent> <C-S-e> :m'>+<CR>gv=gv
|
|
|
|
" Indent lines using <Left> and <Right>
|
|
vmap <C-S-Right> >gv
|
|
nmap <C-S-Right> >>
|
|
imap <C-S-Right> <Esc>>>i
|
|
vmap <C-S-Left> <gv
|
|
nmap <C-S-Left> <<
|
|
imap <C-S-Left> <Esc><<i
|
|
|
|
" moving through location list items
|
|
" noremap <S-Up> :lprevious<CR>
|
|
" noremap <S-Down> :lnext<CR>
|
|
|
|
" moving through buffers
|
|
" noremap <S-Left> :bn<CR>
|
|
" noremap <S-Right> :bp<CR>
|
|
noremap <leader>bd <Esc>:bd<CR>
|
|
noremap <leader>wc <Esc>:bd<CR>
|
|
noremap <leader>bo <Esc>:Bufonly<CR>
|
|
|
|
" close preview
|
|
nmap <leader>pc <Esc>:pc<CR>
|
|
|
|
" Remap window commands
|
|
" map <leader>ws <Esc>:wincmd s<CR>
|
|
" map <leader>wv <Esc>:wincmd v<CR>
|
|
" map <leader>wc <Esc>:wincmd c<CR>
|
|
" map <leader>wn <Esc>:wincmd n<CR>
|
|
" map <leader>wo <Esc>:wincmd o<CR>
|
|
" map <leader>w+ <Esc>:wincmd _<CR>
|
|
" map <leader>w- <Esc>:wincmd <Bar><CR>
|
|
" map <leader>w= <Esc>:wincmd =<CR>
|
|
" nmap + :vertical resize +20<CR>
|
|
" nmap - :vertical resize -20<CR>
|
|
" map <C-S--> <Esc>:wincmd ><CR>
|
|
" map <C-Down> <Esc>:wincmd j<CR>
|
|
" map <C-j> <Esc>:wincmd j<CR>
|
|
" map <C-Up> <Esc>:wincmd k<CR>
|
|
" map <C-k> <Esc>:wincmd k<CR>
|
|
" map <C-Left> <Esc>:wincmd h<CR>
|
|
" map <C-h> <Esc>:wincmd h<CR>
|
|
" map <C-Right> <Esc>:wincmd l<CR>
|
|
" map <C-l> <Esc>:wincmd l<CR>
|
|
"
|
|
" nnoremap <silent> <A-o> :wincmd k<CR>
|
|
" nnoremap <silent> <A-e> :wincmd j<CR>
|
|
" nnoremap <silent> <A-n> :wincmd h<CR>
|
|
" nnoremap <silent> <A-i> :wincmd l<CR>
|
|
" inoremap <silent> <A-o> <Esc>:wincmd k<CR>
|
|
" inoremap <silent> <A-e> <Esc>:wincmd j<CR>
|
|
" inoremap <silent> <A-n> <Esc>:wincmd h<CR>
|
|
" inoremap <silent> <A-i> <Esc>:wincmd l<CR>
|
|
nnoremap <silent> <A-Up> :wincmd k<CR>
|
|
nnoremap <silent> <A-Down> :wincmd j<CR>
|
|
nnoremap <silent> <A-Left> :wincmd h<CR>
|
|
nnoremap <silent> <A-Right> :wincmd l<CR>
|
|
inoremap <silent> <A-Up> <Esc>:wincmd k<CR>
|
|
inoremap <silent> <A-Down> <Esc>:wincmd j<CR>
|
|
inoremap <silent> <A-Left> <Esc>:wincmd h<CR>
|
|
inoremap <silent> <A-Right> <Esc>:wincmd l<CR>
|
|
nnoremap <silent> <C-A-Up> :wincmd K<CR>
|
|
nnoremap <silent> <C-A-Down> :wincmd J<CR>
|
|
nnoremap <silent> <C-A-Left> :wincmd H<CR>
|
|
nnoremap <silent> <C-A-Right> :wincmd L<CR>
|
|
inoremap <silent> <C-A-Up> <Esc>:wincmd K<CR>
|
|
inoremap <silent> <C-A-Down> <Esc>:wincmd J<CR>
|
|
inoremap <silent> <C-A-Left> <Esc>:wincmd H<CR>
|
|
inoremap <silent> <C-A-Right> <Esc>:wincmd L<CR>
|
|
|
|
" tags
|
|
nmap <S-F3> :exec("tjump ".expand("<cword>"))<CR>
|
|
nmap <S-F4> :split<CR>:exec("tjump ".expand("<cword>"))<CR>
|
|
|
|
" trigger NERDTree, Tagbar $ Co.
|
|
nmap <leader>n <Esc>:NERDTreeToggle<CR>
|
|
nmap <leader>t <Esc>:TagbarToggle<CR>
|
|
" nmap <leader>f "zyaw :exe ":Ack ".@z.""<CR>
|
|
nmap <C-f> :CtrlP<CR>
|
|
nmap <C-t> :CtrlPTag<CR>
|
|
nmap <C-b> :CtrlPBuffer<CR>
|
|
|
|
" grep word under cursor
|
|
nnoremap <silent><leader>f :lgr! "\b<C-R><C-W>\b"<CR>:cw<CR>
|
|
|
|
" paste from system clipboard
|
|
inoremap <silent> <S-Insert> <ESC>:set paste<CR>"+p :set nopaste<CR>
|
|
|
|
" toggle spellcheck
|
|
nmap <silent> <S-F7> :setlocal spell! spelllang=en_us<CR>
|
|
|
|
" cursor jump
|
|
" nnoremap <A-Up> 3k
|
|
" inoremap <A-Up> <Esc>:-3<CR>i
|
|
" vnoremap <A-Up> 3k
|
|
" nnoremap <A-Down> 3j
|
|
" inoremap <A-Down> <Esc>:+3<CR>i
|
|
" vnoremap <A-Down> 3j
|
|
" nnoremap <C-Up> 6k
|
|
" inoremap <C-Up> <Esc>:-6<CR>i
|
|
" vnoremap <C-Up> 6k
|
|
" nnoremap <C-Down> 6j
|
|
" inoremap <C-Down> <Esc>:+6<CR>i
|
|
" vnoremap <C-Down> 6j
|
|
|
|
nnoremap <A-o> 3k
|
|
vnoremap <A-o> 3k
|
|
nnoremap <A-e> 3j
|
|
vnoremap <A-e> 3j
|
|
nnoremap <C-o> 6k
|
|
vnoremap <C-o> 6k
|
|
nnoremap <C-e> 6j
|
|
vnoremap <C-e> 6j
|
|
|
|
" scrolling
|
|
nnoremap <S-PageUp> 10<C-Y>
|
|
inoremap <S-PageUp> <Esc>10<C-Y>i
|
|
vnoremap <S-PageUp> 10<C-Y>
|
|
nnoremap <S-PageDown> 10<C-E>
|
|
inoremap <S-PageDown> <Esc>10<C-E>i
|
|
vnoremap <S-PageDown> 10<C-E>
|
|
|
|
nnoremap <C-p> 10<C-Y>
|
|
inoremap <C-p> <Esc>10<C-Y>i
|
|
vnoremap <C-p> 10<C-Y>
|
|
nnoremap <C-u> 10<C-E>
|
|
inoremap <C-u> <Esc>10<C-E>i
|
|
vnoremap <C-u> 10<C-E>
|
|
|
|
|
|
" F keys
|
|
nmap <F2> :noh<CR>
|
|
imap <F2> <C-O>:noh<CR>
|
|
nmap <F3> :YcmCompleter GoToDeclaration<CR>
|
|
nmap <F4> :YcmCompleter GoTo<CR>
|
|
nmap <C-F4> :YcmCompleter GoTo<CR>:wincmd o<CR>
|
|
noremap <F5> :FufBuffer<CR>
|
|
nmap <F7> :call ManCurrentWord()<CR><CR>
|
|
nmap <F8> :call DevHelpCurrentWord()<CR><CR>
|
|
nnoremap <silent> <F10> :call NERDComment("n", "Toggle")<cr>
|
|
vnoremap <silent> <F10> <ESC>:call NERDComment("v", "Toggle")<cr>
|
|
" nmap <F4> <C-]>
|
|
|
|
" plugins etc
|
|
noremap <C-F> :NERDTreeToggle<CR>
|
|
noremap <C-B> :TagbarToggle<CR>
|
|
inoremap <C-B> <C-O>:TagbarToggle<CR>
|
|
|
|
" remap visual block
|
|
nnoremap <S-C> <c-v>
|
|
|
|
" write
|
|
noremap <C-s> :w<CR>
|
|
inoremap <C-s> <C-O>:w<CR>
|
|
|
|
" exit
|
|
noremap <C-q> :qa!<CR>
|
|
inoremap <C-q> <C-O>:qa!<CR>
|
|
|
|
" paste
|
|
nnoremap <C-V> "+gPl
|
|
vnoremap <C-V> :<C-U>call Paste("v")<CR>
|
|
inoremap <C-V> <C-O>:call Paste("i")<CR>
|
|
|
|
" select all
|
|
nnoremap <C-A> ggVG<CR>
|
|
inoremap <C-A> <C-O>:call Select()<CR>
|
|
|
|
" fzf
|
|
nnoremap <leader>ag :call fzf#vim#ag(expand('<cword>'), WithGitRoot())<CR>
|
|
nnoremap <leader>tg :call fzf#vim#tags(expand('<cword>'), {'options': '--exact --select-1 --exit-0'})<CR>
|
|
|
|
" gitgutter
|
|
nmap <leader>ggt <Esc>:GitGutterToggle<CR>
|
|
nmap <leader>nh <Plug>(GitGutterNextHunk)
|
|
nmap <leader>bh <Plug>(GitGutterPrevHunk)
|
|
|
|
" ctrlp
|
|
let g:ctrlp_prompt_mappings = {
|
|
\ 'PrtBS()': ['<bs>', '<c-]>'],
|
|
\ 'PrtDelete()': ['<del>'],
|
|
\ 'PrtDeleteWord()': ['<c-w>'],
|
|
\ 'PrtClear()': ['<c-u>'],
|
|
\ 'PrtSelectMove("j")': ['<c-e>', '<down>'],
|
|
\ 'PrtSelectMove("k")': ['<c-o>', '<up>'],
|
|
\ 'PrtSelectMove("t")': ['<Home>', '<kHome>'],
|
|
\ 'PrtSelectMove("b")': ['<End>', '<kEnd>'],
|
|
\ 'PrtSelectMove("u")': ['<PageUp>', '<kPageUp>'],
|
|
\ 'PrtSelectMove("d")': ['<PageDown>', '<kPageDown>'],
|
|
\ 'PrtHistory(-1)': ['<c-f>'],
|
|
\ 'PrtHistory(1)': ['<c-p>'],
|
|
\ 'AcceptSelection("e")': ['<cr>', '<2-LeftMouse>'],
|
|
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>'],
|
|
\ 'AcceptSelection("t")': ['<c-t>'],
|
|
\ 'AcceptSelection("v")': ['<c-v>', '<RightMouse>'],
|
|
\ 'ToggleFocus()': ['<s-tab>'],
|
|
\ 'ToggleRegex()': ['<c-r>'],
|
|
\ 'ToggleByFname()': ['<c-d>'],
|
|
\ 'ToggleType(1)': ['<c-g>', '<c-up>'],
|
|
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
|
|
\ 'PrtExpandDir()': ['<tab>'],
|
|
\ 'PrtInsert("c")': ['<MiddleMouse>', '<insert>'],
|
|
\ 'PrtInsert()': ['<c-\>'],
|
|
\ 'PrtCurStart()': ['<c-a>'],
|
|
\ 'PrtCurEnd()': ['<c-k>'],
|
|
\ 'PrtCurLeft()': ['<c-n>', '<left>', '<c-^>'],
|
|
\ 'PrtCurRight()': ['<c-i>', '<right>'],
|
|
\ 'PrtClearCache()': ['<F5>'],
|
|
\ 'PrtDeleteEnt()': ['<F7>'],
|
|
\ 'CreateNewFile()': ['<c-y>'],
|
|
\ 'MarkToOpen()': ['<c-z>'],
|
|
\ 'OpenMulti()': ['<c-l>'],
|
|
\ 'PrtExit()': ['<esc>', '<c-c>', '<c-g>'],
|
|
\ }
|
|
|
|
|
|
nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>
|