This repository has been archived on 2021-12-21. You can view files and clone it, but cannot push or open issues/pull-requests.
neovim-config/init/keys.vim

88 lines
2.3 KiB
VimL

" Keep cursor centered as much as possible
nnoremap j jzz
nnoremap k kzz
nnoremap gg ggzz
nnoremap G Gzz
" Navigate between ctags
" Jump to definition
" nnoremap gd <C-]>
" Go back up stack
" nnoremap gb <C-t>
" Remap split navigation keybindings
nnoremap <silent> <leader>h :wincmd h<CR>
nnoremap <silent> <leader>j :wincmd j<CR>
nnoremap <silent> <leader>k :wincmd k<CR>
nnoremap <silent> <leader>l :wincmd l<CR>
" Write using <leader>+w
nnoremap <silent> <leader>w :w<CR>
" Quit using <leader>+q
nnoremap <silent> <leader>q :q<CR>
" Use arrow keys for split resizing in normal mode
nnoremap <silent> <Up> :resize +3<CR>
nnoremap <silent> <Down> :resize -3<CR>
nnoremap <silent> <Right> :vertical resize +3<CR>
nnoremap <silent> <Left> :vertical resize -3<CR>
" Disable arrow keys in editing & visual mode
inoremap <Right> <nop>
inoremap <Left> <nop>
inoremap <Up> <nop>
inoremap <Down> <nop>
vnoremap <Right> <nop>
vnoremap <Left> <nop>
vnoremap <Up> <nop>
vnoremap <Down> <nop>
" Tabs bindings
" Create tab
nnoremap <silent> <leader>o :tabnew<CR>
" Close current tab
nnoremap <silent> <leader>p :tabclose<CR>
" Go to next tab
nnoremap <silent> <leader>i :tabnext<CR>
" Go to previous tab
nnoremap <silent> <leader>u :tabprevious<CR>
" Make commands
nnoremap <silent> <leader>mr :make! run<CR>
nnoremap <silent> <leader>mt :make! test<CR>
" Keybinding for switching between light/dark colorschemes
function! ColorschemeToggle()
if g:colors_name == 'flattened_dark'
colorscheme flattened_light
else
colorscheme flattened_dark
endif
endfunction
nnoremap <silent> <leader>c :call ColorschemeToggle()<CR>
" Quick config editing
" Re-source vimrc/init.vim
nnoremap <silent> <leader>vs :source $MYVIMRC<CR>
" Open CtrlP in config directory
nnoremap <silent> <leader>ve :split<CR>:exec 'CtrlP ' . fnamemodify($MYVIMRC, ':h')<CR>
" Overwrite Esc (experiment)
inoremap jk <Esc>
inoremap <Esc> <nop>
" Switch between 2 files quickly
nnoremap <leader>a <C-^>
" Terminal keybindings
" Use jk in terminal as well
tnoremap <silent> jk <C-\><C-n>
" Open terminal in different locations
nnoremap <silent> <leader>rr :terminal<CR>
nnoremap <silent> <leader>rh :vsp<CR>:wincmd h<CR>:term<CR>
nnoremap <silent> <leader>rl :vsp<CR>:term<CR>
nnoremap <silent> <leader>rk :sp<CR>:wincmd k<CR>:term<CR>
nnoremap <silent> <leader>rj :sp<CR>:term<CR>