From 5a70f2dc734995cfa3fff3455771a0d67a440ae3 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 10 Mar 2023 11:03:48 +0200 Subject: [.vim] Reworked mappings and options --- .vim/startup/mappings.vim | 108 ++++++++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 46 deletions(-) (limited to '.vim/startup/mappings.vim') diff --git a/.vim/startup/mappings.vim b/.vim/startup/mappings.vim index 1ed6f8a..c2a9b03 100644 --- a/.vim/startup/mappings.vim +++ b/.vim/startup/mappings.vim @@ -1,3 +1,62 @@ +" Ctrl-C, Ctrl-V, ... {{{ + " Partly taken from: https://gist.github.com/jshih/3423345 + " Most use "li" instead of "i" because for some (good?) reason my cursor + " goes to the right after executing any of those + inoremap :wli + inoremap "+pli + inoremap ggVG + inoremap i + inoremap uli + + nnoremap :w + nnoremap ggVG + + xnoremap c"+Pl + xnoremap ggVG + xnoremap "+y + xnoremap "+d +" }}} + +" Move lines with Alt-J, Alt-K {{{ + execute "set =\ej" + nnoremap :m+1 + execute "set =\ek" + nnoremap :m-2 + + xnoremap :m '>+1gv=gv + xnoremap :m '<-2gv=gv +" }}} + +" Omni completion (really needs a rework) {{{ + " Omni completion supports C, HTML, CSS, JavaScript, PHP, Python, Ruby, SQL, XML + set omnifunc=syntaxcomplete#Complete " Completion for all supported languages + + " Do omni completion from Ctrl+Space + inoremap + + " Thanks to: https://vim.fandom.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE + " set completeopt=longest,menuone + " [ The following are disabled, because they conflict with delimitMate's autobracket feature ] + " inoremap pumvisible() ? "\" : "\u\" + " inoremap pumvisible() ? '' : '=pumvisible() ? "\Down>" : ""' + + " "Disables" arrow navigation in completion menu + inoremap pumvisible() ? '' : '' + inoremap pumvisible() ? '' : '' + + " Pressing tab goes from top to bottom + let g:SuperTabContextDefaultCompletionType = "" +" }}} + +" When line is wrapped, going up or down will also go into the wrapped part +nnoremap j gj +nnoremap k gk +xnoremap j gj +xnoremap k gk + +" Don't move cursor one character back on esc key press +inoremap :stopinsert + " Don't get into insert mode after adding a line with o/O nnoremap o o nnoremap O O @@ -6,36 +65,14 @@ nnoremap O O inoremap inoremap -" Ctrl+s; Ctrl+c, Ctrl+v, Ctrl+x; Ctrl+z, Ctrl+r; Ctrl+a bindings that work on GUI applications -" Partly taken from: https://gist.github.com/jshih/3423345 -imap :wi -nmap :w -"imap An impossible dream -vmap "+yi -vmap c"+P -imap "+Pi -vmap "+c -imap ui -imap i -map ggVG - -" Show all buffers and be able to just type in the number of the buffer -map :set nomore:ls:set more:b - -" Move a line up and down with Alt+k and Alt-j -execute "set =\ej" -nnoremap :m+1 -execute "set =\ek" -nnoremap :m-2 -vnoremap :m '>+1gv=gv -vnoremap :m '<-2gv=gv - " Make session file nnoremap :mksession! .vim-session + " Show who edited the current line from git history nnoremap :call gitblame#echo() + " Open lazygit in a new tab with = -nnoremap = :tab ter ++close lazygit +nnoremap = :tab ter ++close lazygit " Cyrillic (Bulgarian yawerty layout) support ca в w @@ -50,24 +87,3 @@ ca xa wa qa! " Open a terminal vim tab with tt and open a blank tab with te ca tt tab ter ca te tabe - -" Omni completion {{{ - " Omni completion supports C, HTML, CSS, JavaScript, PHP, Python, Ruby, SQL, XML - set omnifunc=syntaxcomplete#Complete " Completion for all supported languages - - " Do omni completion from Ctrl+Space - inoremap - - " Thanks to: https://vim.fandom.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE - " set completeopt=longest,menuone - " [ The following are disabled, because they conflict with delimitMate's autobracket feature ] - " inoremap pumvisible() ? "\" : "\u\" - " inoremap pumvisible() ? '' : '=pumvisible() ? "\Down>" : ""' - - " "Disables" arrow navigation in completion menu - inoremap pumvisible() ? '' : '' - inoremap pumvisible() ? '' : '' - - " Pressing tab goes from top to bottom - let g:SuperTabContextDefaultCompletionType = "" -" }}} -- cgit v1.2.3