vim/vimrc.d/mappings.vim

141 lines
3.5 KiB
VimL
Raw Normal View History

2018-03-17 23:59:01 +00:00
" key #mappings{{{
2018-03-28 23:17:30 +00:00
let g:mapleader = ' '
2018-03-17 23:59:01 +00:00
2018-03-28 23:03:11 +00:00
" miscallaneous
"{{{
nnoremap : :setlocal norelativenumber<CR>:
2018-03-20 22:20:40 +00:00
nnoremap <silent> <space>rc :so $MYVIMRC<CR>
2018-03-28 23:03:11 +00:00
nnoremap <silent> <space>nn :set invrelativenumber<CR>
nnoremap <silent><expr> <space>nh (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n"
2018-05-28 15:18:39 +00:00
nnoremap <silent> <space>sw :set invlist<CR>
2018-05-20 19:45:10 +00:00
" inoremap jk <esc>
2018-03-28 23:03:11 +00:00
nnoremap <silent> A :call CheckLineEnding()<CR>
nnoremap <space>co :!clear;
2018-03-17 23:59:01 +00:00
" Focus on current fold, close the rest
2018-03-20 22:20:40 +00:00
nnoremap <silent> <space>zz zMzvzt
2018-03-17 23:59:01 +00:00
" replace current word with last yanked/deleted text
2018-03-20 22:20:40 +00:00
nnoremap <silent> <space>rr "_diwP
2018-03-17 23:59:01 +00:00
" replace current word with last yanked text
2018-03-20 22:20:40 +00:00
nnoremap <silent> <space>ry diw"0P
2018-03-28 23:03:11 +00:00
" quick grep of visual selection
vnoremap <space>gr y:grep! -R <C-r>" .
" open quickfix window of TODOs
nnoremap <space>td :grep! -R '// *TODO' .<CR>:botright cwindow<CR>:echo len(getqflist()) 'TODOs'<CR>
" devdocs mapping
nnoremap <space>dd :DD<CR>
2018-03-17 23:59:01 +00:00
2018-03-28 23:03:11 +00:00
"}}}
2018-03-17 23:59:01 +00:00
2018-03-28 23:03:11 +00:00
" git mappings
"{{{
2018-03-28 20:03:57 +00:00
nnoremap <space>gs :Gstatus<CR>
nnoremap <space>gd :Gdiff<CR>
nnoremap <space>gD :!clear; echo 'git diff'; git diff<CR>
2018-03-17 23:59:01 +00:00
nnoremap <space>ga :!clear; git add %; git status<CR>
nnoremap <space>gA :!clear; git add .; git status<CR>
2018-03-28 21:46:48 +00:00
nnoremap <space>gc :Gcommit<CR>
2018-03-17 23:59:01 +00:00
nnoremap <space>gg :!clear; git add %; git commit -m ''<Left>
2018-03-28 22:23:02 +00:00
nnoremap <space>gp :!clear; echo 'git push'; git push<CR>
2018-03-28 23:03:11 +00:00
" nnoremap <space>gp :terminal echo ':git push' & git push<CR>
2018-03-28 22:23:02 +00:00
" nnoremap <space>gp :Gpush<CR>
2018-03-28 23:03:11 +00:00
" nnoremap <space>gp :pedit | read ! echo 'git push'; git push<CR>
2018-03-28 21:46:48 +00:00
nnoremap <space>gl :Glog<CR>
2018-03-28 23:03:11 +00:00
"}}}
2018-03-17 23:59:01 +00:00
" netrw
2018-03-28 23:03:11 +00:00
"{{{
2018-03-17 23:59:01 +00:00
nnoremap <space>ex :Ex<CR>
nnoremap <space>ee :e .<CR>
nnoremap <space>eq :Rex<CR>
2018-03-28 23:03:11 +00:00
"}}}
2018-03-17 23:59:01 +00:00
2018-05-28 20:32:07 +00:00
" better window/tab/buffer navigation/management
2018-03-28 23:03:11 +00:00
"{{{
2018-03-17 23:59:01 +00:00
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
nnoremap <C-k> <C-w>k
nnoremap <C-j> <C-w>j
nnoremap <Esc>j :resize -5<CR>
nnoremap <Esc>k :resize +5<CR>
nnoremap <Esc>l :vertical resize +5<CR>
nnoremap <Esc>h :vertical resize -5<CR>
nnoremap <Esc>= <C-w>=
2018-03-28 23:16:30 +00:00
nnoremap <space><space>h :vsplit<CR>
nnoremap <space><space>l :vsplit<CR><C-w>l
nnoremap <space><space>j :split<CR><C-w>j
nnoremap <space><space>k :split<CR><C-w>k
nnoremap <space><space>t :tabnew<CR>
2018-03-29 08:55:18 +00:00
nnoremap <space><space>z :tabnew %<CR>
2018-03-29 20:37:37 +00:00
nnoremap <space><space>q :tabclose<CR>gT<CR>
2018-04-08 16:45:30 +00:00
2018-05-01 22:33:01 +00:00
nnoremap <space># :b#<CR>
2018-05-28 20:32:07 +00:00
nnoremap <silent> <Tab> :bnext<CR>
nnoremap <silent> <S-Tab> :bprev<cr>
2018-03-28 23:03:11 +00:00
"}}}
2018-03-17 23:59:01 +00:00
"location list and quickfix mappings
2018-03-28 23:03:11 +00:00
"{{{
2018-03-18 17:52:48 +00:00
nnoremap <space>lo :botright lwindow<CR>
nnoremap <up> :lprev<CR>zv
nnoremap <down> :lnext<CR>zv
2018-03-17 23:59:01 +00:00
nnoremap <space>lc :lclose<CR>
2018-03-18 17:52:48 +00:00
nnoremap <space>lh :lhistory<CR>
nnoremap <space>lp :lolder<CR>
nnoremap <space>ln :lnewer<CR>
2018-03-17 23:59:01 +00:00
2018-03-18 17:52:48 +00:00
nnoremap <space>qo :botright cwindow<CR>
nnoremap <left> :cprev<CR>zv
nnoremap <right> :cnext<CR>zv
2018-03-17 23:59:01 +00:00
nnoremap <space>qc :cclose<CR>
2018-03-18 17:52:48 +00:00
nnoremap <space>qh :chistory<CR>
nnoremap <space>qp :colder<CR>
nnoremap <space>qn :cnewer<CR>
2018-03-28 23:03:11 +00:00
"}}}
2018-03-17 23:59:01 +00:00
2018-05-01 22:58:03 +00:00
" insert mode mappings
"{{{
inoremap RR <c-o>:reg<cr>
"}}}
2018-03-17 23:59:01 +00:00
" brace/quotes completion
2018-03-28 23:03:11 +00:00
"{{{
2018-05-08 20:35:14 +00:00
inoremap { {}<left>
2018-05-13 19:46:53 +00:00
inoremap {} {}
2018-05-08 20:35:14 +00:00
inoremap {<CR> {<CR>}<C-o>O
inoremap {; {<CR>};<C-o>O
inoremap {{ {{}}<Left><Left>
2018-05-08 21:21:27 +00:00
inoremap {{{ {{
2018-03-17 23:59:01 +00:00
2018-06-08 14:35:11 +00:00
inoremap ( ()<Left>
inoremap () ()
2018-05-08 20:35:14 +00:00
inoremap (<CR> (<CR>)<C-o>O
2018-06-08 14:35:11 +00:00
inoremap (; ();<Left><Left>
2018-03-17 23:59:01 +00:00
2018-06-08 14:35:11 +00:00
inoremap [ []<Left>
inoremap [] []
inoremap [<CR> [<CR>]<C-o>O
2018-03-17 23:59:01 +00:00
2018-06-08 14:35:11 +00:00
inoremap "" ""<Left>
inoremap """ ""
inoremap "; "";<Left><Left>
inoremap '' ''<Left>
inoremap ''' ''
inoremap '; '';<Left><Left>
2018-03-17 23:59:01 +00:00
2018-03-28 23:03:11 +00:00
"}}}
2018-03-17 23:59:01 +00:00
"}}}
2018-05-08 21:28:12 +00:00
" #abbreviations
"{{{
2018-03-17 23:59:01 +00:00
iabbrev adn and
iabbrev waht what
iabbrev tehn then
"}}}
" vim: foldmethod=marker