" 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 " set our leader key to space since with hjkl, space is largely useless let mapleader = "\" " maps the leader for buffer local mappings (e.g. vim-waikiki for files under " the root dir to the same key -- might lead to incompatibilities, will have " to test) let maplocalleader = "\" " set jk to escape, in case capslock is not mapped to escape on the system inoremap jk " 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 " move around between matching brackets with tab nnoremap % nnoremap % " Spell check set to O, 'o' for 'orthography': noremap O :setlocal spell! spelllang=en_us noremap OE :setlocal spell! spelllang=en_us noremap OG :setlocal spell! spelllang=de_de noremap o z= " select the whole buffer with -a nnoremap a ggVG " 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 " since u undoes, would it not make sense that U redoes? nnoremap U " when in insertion mode, C-u uppercases the current word, C-l lowercases it, inoremap gUiw`]a inoremap guiw`]a " get rid of the help message popping up when I miss esc and hit F1 nnoremap inoremap vnoremap " yank filename to f buffer nnoremap yf :let @f = expand("%") " remove all trailing whitespaces " on pressing space+W nnoremap W :%s/\s\+$//:let @/='' " automatically on saving " autocmd BufWritePre * :%s/\s\+$//e " 'open new buffer' with leader-t (opens new buffer and switches to it) " open actual new tab with leader-T nnoremap t :vsp . nnoremap T :tabedit . " 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 " 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) " Configure notational-fzf-vim let g:nv_search_paths = [ g:wiki_root ] let g:nv_wrap_preview_text=1 " Dictionary with string keys and values. Must be in the form 'ctrl-KEY': " 'command' or 'alt-KEY' : 'command'. See examples below. 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', \ ] " Markdown & Pandoc compilation group " the commented out command can be used if vim-rmarkdown plugin is not " installed (it is a bit more brittle) " autocmd FileType rmd noremap :!echo"require(rmarkdown);render('%')"\|R--vanilla " Compile with rmarkdown " autocmd FileType markdown,rmarkdown noremap c :RMarkdown pdf " autocmd FileType markdown,rmarkdown noremap C :RMarkdown! pdf function! SearchWiki() let l:curpath=getcwd() :execute(":cd " . g:wiki_root) let l:texttofind=input("Search in Notes: ") :execute(":CtrlSF " . l:texttofind) :CtrlSFFocus :execute(":cd " . l:curpath) endfunction " search in wiki with ctrlsf, in fullscreen window nnoremap wf :execute(":call SearchWiki()") " 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 noremap f :FzfFiles " use wiki.vim to look through document outlines in fzf (only for note " directory atm) nnoremap l :WikiFzfToc " FZF general full-text search in cwd with rg noremap F :FzfRg " FZF note full-text search with notational-velocity like functions (in wiki " directory) noremap n :NV noremap N :NV! " FZF git diff noremap gd :FzfGFiles? " FZF colorschemes nnoremap :FzfColors " Toggle background light/dark call togglebg#map("") " 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 " Enter distraction free prose mode with F11 noremap :Goyo " surround stuff with quotes, from normal or visual mode nnoremap " viwa"bi"lel vnoremap " ``>la"l " stronger versions of left,right - move all the way nnoremap H ^ nnoremap L $