vim-config/plugin/keys.vim
2020-06-14 21:43:04 +02:00

230 lines
5.5 KiB
VimL

" workman
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>
nnoremap <c-n> b
nnoremap <c-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>
nnoremap <SPACE> <Nop>
let g:mapleader = ' '
" 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!
" Bubble single lines
nmap <silent> <C-S-Up> :m-2<CR>==
nmap <silent> <C-S-Down> :m+<CR>==
imap <silent> <C-S-Up> <Esc>:m-2<CR>==gi
imap <silent> <C-S-Down> <Esc>:m+<CR>==gi
" Bubble multiple lines
vmap <silent> <C-S-Up> :m-2<CR>gv=gv
vmap <silent> <C-S-Down> :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 <C-p> :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>
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>
" 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 <C-A-Up> 3k
inoremap <C-A-Up> <Esc>:-3<CR>i
vnoremap <C-A-Up> 3k
nnoremap <C-A-Down> 3j
inoremap <C-A-Down> <Esc>:+3<CR>i
vnoremap <C-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 <C-A-o> 3k
inoremap <C-A-o> <Esc>:-3<CR>i
vnoremap <C-A-o> 3k
nnoremap <C-A-e> 3j
inoremap <C-A-e> <Esc>:+3<CR>i
vnoremap <C-A-e> 3j
nnoremap <C-o> 6k
inoremap <C-o> <Esc>:-6<CR>i
vnoremap <C-o> 6k
nnoremap <C-e> 6j
inoremap <C-e> <Esc>:+6<CR>i
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>
" 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-B> <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