FollieHiyuki-dotfiles/nvim-old/plugin/keybindings.vim

77 lines
1.9 KiB
VimL
Raw Normal View History

2021-02-13 11:28:59 -05:00
" Better escape
inoremap jk <Esc>
inoremap kj <Esc>
" Better Y
nmap Y y$
" Basic file commands
2021-06-13 06:52:07 -04:00
nnoremap <A-f> :!touch<Space>
2021-02-13 11:28:59 -05:00
nnoremap <A-e> :!crf<Space>
nnoremap <A-d> :!mkdir<Space>
nnoremap <A-m> :!mv<Space>%<Space>
" Shorten default replace command
nnoremap <A-s> :%s//g<Left><Left>
" Delete trailing whitespace
nnoremap <A-w> :%s/\s\+$//e<CR>
" Use alt + hjkl to resize windows
nnoremap <silent> <A-j> :resize -2<CR>
nnoremap <silent> <A-k> :resize +2<CR>
nnoremap <silent> <A-h> :vertical resize -2<CR>
nnoremap <silent> <A-l> :vertical resize +2<CR>
" Better window navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Terminal window navigation
" tnoremap <C-h> <C-\><C-N><C-w>h
" tnoremap <C-j> <C-\><C-N><C-w>j
" tnoremap <C-k> <C-\><C-N><C-w>k
" tnoremap <C-l> <C-\><C-N><C-w>l
tnoremap <Esc> <C-\><C-n>
" Cancel actions
nnoremap <silent> <C-c> <Esc>
inoremap <silent> <C-c> <Esc>i
" Move between buffers
nnoremap <silent> <TAB> :bnext<CR>
nnoremap <silent> <S-TAB> :bprevious<CR>
" Just do it
2021-04-02 20:23:33 -04:00
" cmap w!! w !sudo tee %
2021-02-13 11:28:59 -05:00
" Fix indenting visual block
vmap < <gv
vmap > >gv
" Move selected line / block of text in visual mode
xnoremap K :move '<-2<CR>gv-gv
xnoremap J :move '>+1<CR>gv-gv
" Bad hands
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Qa! qa!
cnoreabbrev QA! qa!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
cnoreabbrev Qa qa
cnoreabbrev QA qa
cnoreabbrev Wqa wqa
cnoreabbrev WQa wqa
2021-06-13 06:52:07 -04:00
function! ToggleIndentStyle()
if &expandtab == 1
set noexpandtab
set softtabstop&
set shiftwidth&
echomsg "Switched to indent with tabs."
else
set expandtab
set softtabstop = 4
set shiftwidth = 4
echomsg "Switched to indent with 4 spaces."
endif
endfunction
noremap <A-t> :call ToggleIndentStyle()<CR>