dotfiles/vim/config/keybindings.vim

102 lines
3.5 KiB
VimL

" No Arrowkeys
no <up> <NOP>
no <down> <NOP>
no <left> <NOP>
no <right> <NOP>
ino <up> <NOP>
ino <down> <NOP>
ino <left> <NOP>
ino <right> <NOP>
vno <up> <NOP>
vno <down> <NOP>
vno <left> <NOP>
vno <right> <NOP>
" Misc Keybindings
let mapleader = ","
" Buffers
nmap <F3> :Buffers<CR>
imap <F3> <ESC><ESC>:Buffers<CR>
vmap <F3> <ESC><ESC>:Buffers<CR>
" Bufferline.nvim
nnoremap <silent>[b :BufferLineCyclePrev<CR>
nnoremap <silent>]b :BufferLineCycleNext<CR>
" Nerdtree
nmap <silent> <F2> <ESC>:NERDTreeToggle<CR>
" Tagbar
nmap <F4> :TagbarToggle<CR>
" SingleCompile
nmap <F8> :SCChooseCompiler<CR>
nmap <F9> :SCCompile<cr>
nmap <F10> :SCCompileRun<cr>
" Window Movement
nnoremap <silent> <C-H> <C-W><C-H>
nnoremap <silent> <C-J> <C-W><C-J>
nnoremap <silent> <C-K> <C-W><C-K>
nnoremap <silent> <C-L> <C-W><C-L>
" Yankstack
nmap <silent> <S-P> <Plug>yankstack_substitute_newer_paste
nmap <silent> <C-P> <Plug>yankstack_substitute_older_paste
" CTRL + Space = Autocomplete
inoremap <C-space> <C-N>
imap <C-@> <C-Space>
cmap w!! w !sudo tee > /dev/null %
" Toggle Case
nmap <C-c> g~iw
" Rmarkdown
autocmd Filetype rmd nmap <F5> :w\|:!echo<space>"require(rmarkdown);<space>render('<c-r>%')"<space>\|<space>R<space>--vanilla<enter>
autocmd Filetype rmd imap <F5> <ESC><ESC>:w\|:!echo<space>"require(rmarkdown);<space>render('<c-r>%')"<space>\|<space>R<space>--vanilla<enter>
map <F1> <Esc>
imap <F1> <Esc>
" nvim smartbuffs
" Jump to the N buffer (by index) according to :ls buffer list
" where N is NOT the buffer number but the INDEX in such list
" NOTE: it does not include terminal buffers
nnoremap <Leader>1 :lua require("nvim-smartbufs").goto_buffer(1)<CR>
nnoremap <Leader>2 :lua require("nvim-smartbufs").goto_buffer(2)<CR>
nnoremap <Leader>3 :lua require("nvim-smartbufs").goto_buffer(3)<CR>
nnoremap <Leader>4 :lua require("nvim-smartbufs").goto_buffer(4)<CR>
nnoremap <Leader>5 :lua require("nvim-smartbufs").goto_buffer(5)<CR>
nnoremap <Leader>6 :lua require("nvim-smartbufs").goto_buffer(6)<CR>
nnoremap <Leader>7 :lua require("nvim-smartbufs").goto_buffer(7)<CR>
nnoremap <Leader>8 :lua require("nvim-smartbufs").goto_buffer(8)<CR>
nnoremap <Leader>9 :lua require("nvim-smartbufs").goto_buffer(9)<CR>
" Improved :bnext :bprev behavior (without considering terminal buffers)
nnoremap <Right> :lua require("nvim-smartbufs").goto_next_buffer()<CR>
nnoremap <Left> :lua require("nvim-smartbufs").goto_prev_buffer()<CR>
" Open terminal buffer and set it as hidden so it won't get deleted
nnoremap <Leader>c1 :lua require("nvim-smartbufs").goto_terminal(1)<CR>
nnoremap <Leader>c2 :lua require("nvim-smartbufs").goto_terminal(2)<CR>
nnoremap <Leader>c3 :lua require("nvim-smartbufs").goto_terminal(3)<CR>
nnoremap <Leader>c4 :lua require("nvim-smartbufs").goto_terminal(4)<CR>
" Delete current buffer and goes back to the previous one
nnoremap <Leader>qq :lua require("nvim-smartbufs").close_current_buffer()<CR>
" Delete the N buffer according to :ls buffer list
nnoremap <Leader>q1 :lua require("nvim-smartbufs").close_buffer(1)<CR>
nnoremap <Leader>q2 :lua require("nvim-smartbufs").close_buffer(2)<CR>
nnoremap <Leader>q3 :lua require("nvim-smartbufs").close_buffer(3)<CR>
nnoremap <Leader>q4 :lua require("nvim-smartbufs").close_buffer(4)<CR>
nnoremap <Leader>q5 :lua require("nvim-smartbufs").close_buffer(5)<CR>
nnoremap <Leader>q6 :lua require("nvim-smartbufs").close_buffer(6)<CR>
nnoremap <Leader>q7 :lua require("nvim-smartbufs").close_buffer(7)<CR>
nnoremap <Leader>q8 :lua require("nvim-smartbufs").close_buffer(8)<CR>
nnoremap <Leader>q9 :lua require("nvim-smartbufs").close_buffer(9)<CR>