" The general ideas behind these mappings: " " * Leader prefix is the generally preferred way to map new things, however " only for those that affect all of vim " " * Localleader prefix is used for mappings which only affect single buffers, " in other words mostly filetype specific mappings " " many of these mapping ideas come from Tom Ryder who has them nicely " documented " backspace to switch to alternate (last) buffer nnoremap " since u undoes, would it not make sense that U redoes? nnoremap U " stronger versions of left,right - move all the way to beginning/end of line nnoremap H ^ nnoremap L $ " move around between matching brackets with tab nnoremap % nnoremap % " when in insertion mode, C-u uppercases the current word, C-l lowercases it, inoremap gUiw`]a inoremap guiw`]a " yank filename to f buffer nnoremap yf :let @f = expand("%") " repeat the last substitute command with all its flags preserved noremap & \ :&& ounmap & sunmap & " bracket pairings to go to the next/previous of: " (works with count prefixes) " " Argument list nnoremap [a \ :previous nnoremap ]a \ :next " Buffers nnoremap [b \ :bprevious nnoremap ]b \ :bnext " Quickfix list nnoremap [c \ :cprevious nnoremap ]c \ :cnext " Location list nnoremap [l \ :lprevious nnoremap ]l \ :lnext " set our leader key to space since with hjkl, space is largely useless let mapleader = "\" " maps the leader for buffer local mappings " since we are (atm) using sneak to go fwd/bwd in fFtT searches, comma does " not do too many useful things and can be taken up as localleader let maplocalleader = "," " If we mapped localleader to comma, we can still get to its original function " by douple-tapping it. if maplocalleader ==# ',' noremap ,, , sunmap ,, endif " remove search highlights by pressing space+/ - the key for searching the " first place nnoremap / :noh " split buffers vertically/horizontally with the leader \ or - (mirrors my " tmux setup) nnoremap - :sp nnoremap \ :vsp " 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it) nnoremap t :vsp . " open actual new tab with leader-T nnoremap T :tabedit . " select the whole buffer with -a nnoremap a ggVG " CONFIG EDITING " quickly edit vimrc with leader+V nnoremap V :vsp $MYVIMRC " automatically source the vimrc file whenever it is saved (causes slowdown " when done in MANY successions) " au BufWritePost init.vim so ~/.config/nvim/init.vim " source vimrc with keystroke combination nnoremap VV :source $MYVIMRC " PLUGIN: vim-sneak map f Sneak_f map F Sneak_F map t Sneak_t map T Sneak_T " SPELL CHECKING " Spell check set to O, 'o' for 'orthography': " Move to the prev/next spelling error with [S ]S " Move to the prev/next spelling error or suggestion with [s ]s noremap O :setlocal spell! spelllang=en_us noremap OE :setlocal spell! spelllang=en_us noremap OG :setlocal spell! spelllang=de_de noremap o z= " PLUGIN: NERDTree " open/close NERDtree with leader-e " whatever method tree has been opened by, leader-e closes it again nnoremap e :NERDTreeToggle " open root of current VCS project in tree nnoremap :NERDTreeVCS " open current nerdtree with current file highlighted nnoremap E :NERDTreeFind " PLUGIN: FZF GLOBAL FUZZY FINDING " FZF buffers and files in current workdir noremap s :FzfBuffers " FZF most recently used / MRU, bound to S since it is essentially a larger " go-back intention than just buffers noremap S :FzfHistory " fuzzy find files in cwd noremap f :FzfFiles " FZF general full-text search in cwd with rg noremap F :FzfRg " FZF git diff noremap gd :FzfGFiles? " FZF colorschemes nnoremap :FzfColors " Toggle background light/dark call togglebg#map("") " Note Searching " PLUGIN: Notational-FZF " set notational-fzf-vim keys for the NV window itself let g:nv_fzf_binds = [ \ 'alt-a:select-all', \ 'alt-q:deselect-all', \ 'alt-p:toggle-preview', \ 'alt-u:page-up', \ 'alt-d:page-down', \ 'ctrl-w:backward-kill-word', \ ] " FZF note full-text search with notational-velocity like functions (in wiki " directory) noremap n :NV noremap N :NV! " PLUGIN: CtrlSF " (non-fuzzy) search in wiki with ctrlsf, in fullscreen window nnoremap wf :execute(":call SearchWiki()") " PLUGIN: vim-go " vim-go mappings - will only activate in go files " most of this credit to https://hackernoon.com/my-neovim-setup-for-go-7f7b6e805876 " switch between test file and function au Filetype go nnoremap ga (go-alternate-edit) " switch between test file and function - in a horizontal/vertical split au Filetype go nnoremap gah (go-alternate-split) au Filetype go nnoremap gav (go-alternate-vertical) " run a test (but run it as short version, in case tests are tagged " accordingly) au FileType go nnoremap :GoTest -short " show/hide code coverage of go file au FileType go nnoremap :GoCoverageToggle -short " To get the documentation of whatever you are hovering over press K (to go " back C-t) -- this is enabled by default and needs no bind " go to the definition of whatever you hover over au FileType go nnoremap (go-def) " PLUGIN: wiki.vim " use wiki.vim to look through document outlines in fzf (only for note " directory atm) nnoremap l :WikiFzfToc " overwrites some default mappings I don't use, or that interfere with my own " mappings TODO: currently this just assigns bogus shortcuts, since the plugin grumbles " when setting to an empty string let g:wiki_mappings_global = { \ '(wiki-journal)' : '===', \ '(wiki-code-run)' : '====', \ '(wiki-graph-in)' : '====', \ '(wiki-graph-out)' : '=====', \ '(wiki-link-toggle)' : '=======', \ '(wiki-page-toc)' : '=========', \ '(wiki-page-toc-local)' : '=============', \ '(wiki-export)' : '==============', \ '(wiki-list-uniq)' : '===============', \ '(wiki-list-uniq-local)' : '================', \ '(wiki-tag-list)' : '=================', \ '(wiki-tag-reload)' : '==================', \ '(wiki-tag-search)' : '=====================', \ '(wiki-link-toggle-operator)' : '======================', \} " Mostly dealing with Prose writing from here on out " Format current Paragraph (esp useful in prose writing) nnoremap q gqap xnoremap q gq nnoremap Q vapJgqap " PLUGIN: GOYO " Enter distraction free prose mode with F11 noremap :Goyo " PLUGIN: fzf-bibtex " map @@ to automatically insert citation reference at cursor inoremap @@ u:call fzf#run(fzf#wrap({ \ 'source': bibtex_ls(), \ 'sink*': function('bibtex_cite_sink_insert'), \ 'up': '25%', \ 'options': '--ansi --multi --prompt "Cite> "'})) " map cc to insert a complete citation at cursor nnoremap cc :CiteRef " map cm to insert markdown prettified citation nnoremap cm :CiteMarkdown