From 9234352b8c33d579b1aa1f92fcfeea2c14eed3f6 Mon Sep 17 00:00:00 2001 From: amix Date: Sat, 30 Nov 2019 12:54:13 +0100 Subject: [PATCH] Improved the mappings documentation Especially for plugins. Fixes https://github.com/amix/vimrc/issues/493 --- README.md | 92 +++++++++++++++++++++++++++------------ vimrcs/basic.vim | 4 +- vimrcs/extended.vim | 2 +- vimrcs/filetypes.vim | 4 +- vimrcs/plugins_config.vim | 19 +++----- 5 files changed, 76 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index befd7d54..4f8ef721 100644 --- a/README.md +++ b/README.md @@ -150,31 +150,6 @@ You can also install your plugins, for instance, via pathogen you can install [v The [leader](http://learnvimscriptthehardway.stevelosh.com/chapters/06.html#leader) is `,`, so whenever you see `` it means `,`. -### Plugin related mappings - -Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) to see and manage the current buffers (`o`): - - map o :BufExplorer - -Open [MRU.vim](https://github.com/vim-scripts/mru.vim) to see the recently open files (`f`): - - map f :MRU - -Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin to quickly find a file or a buffer (`j` or `f`): - - let g:ctrlp_map = '' - -[NERD Tree](https://github.com/scrooloose/nerdtree) mappings: - - map nn :NERDTreeToggle - map nb :NERDTreeFromBookmark - map nf :NERDTreeFind - -[goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2) lets you only focus on one thing at a time. It removes all the distractions and centers the content. It has a special look when editing Markdown, reStructuredText and textfiles. It only has one mapping. (`z`) - - map z :Goyo - - ### Normal mode mappings Fast saving of a buffer (`w`): @@ -184,7 +159,7 @@ Fast saving of a buffer (`w`): Map `` to `/` (search) and `+` to `?` (backwards search): map / - map ? + map ? map :noh Disable highlights when you press ``: @@ -215,7 +190,7 @@ Useful mappings for managing tabs: " Opens a new tab with the current buffer's path " Super useful when editing files in the same directory - map te :tabedit =expand("%:p:h")/ + map te :tabedit =expand("%:p:h")/ Switch [CWD](http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file) to the directory of the open buffer: @@ -273,7 +248,7 @@ Quickly insert parenthesis/brackets/etc.: Insert the current date and time (useful for timestamps): - iab xdate =strftime("%d/%m/%y %H:%M:%S") + iab xdate =strftime("%d/%m/%y %H:%M:%S") ### Command line mappings @@ -296,6 +271,67 @@ Write the file as sudo (works only on Unix). Super useful when you open a file a :W +### Plugin related mappings + +Open [bufexplorer](https://github.com/vim-scripts/bufexplorer.zip) to see and manage the current buffers (`o`): + + map o :BufExplorer + +Open [MRU.vim](https://github.com/vim-scripts/mru.vim) to see the recently open files (`f`): + + map f :MRU + +Open [ctrlp.vim](https://github.com/kien/ctrlp.vim) plugin to quickly find a file or a buffer (`j` or `f`): + + let g:ctrlp_map = '' + +[NERD Tree](https://github.com/scrooloose/nerdtree) mappings: + + map nn :NERDTreeToggle + map nb :NERDTreeFromBookmark + map nf :NERDTreeFind + +[goyo.vim](https://github.com/junegunn/goyo.vim) and [vim-zenroom2](https://github.com/amix/vim-zenroom2) lets you only focus on one thing at a time. It removes all the distractions and centers the content. It has a special look when editing Markdown, reStructuredText and textfiles. It only has one mapping. (`z`) + + map z :Goyo + +[vim-multiple-cursors](https://github.com/terryma/vim-multiple-cursors) mappings to manage multiple cursors at once: + + let g:multi_cursor_start_word_key = '' + let g:multi_cursor_select_all_word_key = '' + let g:multi_cursor_start_key = 'g' + let g:multi_cursor_select_all_key = 'g' + let g:multi_cursor_next_key = '' + let g:multi_cursor_prev_key = '' + let g:multi_cursor_skip_key = '' + let g:multi_cursor_quit_key = '' + +[vim-yankstack](https://github.com/maxbrunsfeld/vim-yankstack) mappings to manage the kill-ring (clipboard): + + nmap yankstack_substitute_older_paste + nmap yankstack_substitute_newer_paste + +[ctrl-p](https://github.com/ctrlpvim/ctrlp.vim) mappings to easily find and open a file, buffer, etc.: + + let g:ctrlp_map = '' + map j :CtrlP + map :CtrlPBuffer + +[vim-snipmate](https://github.com/garbas/vim-snipmate) mappings to autocomplete via snippets: + + ino =snipMate#TriggerSnippet() + snor i=snipMate#TriggerSnippet() + +[vim-surround](https://github.com/tpope/vim-surround) mappings to easily surround a string with `_()` gettext annotation: + + vmap Si S(i_f) + au FileType mako vmap Si S"i${ _(2f"a) } + +[ale](https://github.com/dense-analysis/ale) to easily go to the next Ale syntax/lint error: + + nmap a (ale_next_wrap) + + ### Spell checking Pressing `ss` will toggle spell checking: diff --git a/vimrcs/basic.vim b/vimrcs/basic.vim index 91d3e71a..42e90fe0 100644 --- a/vimrcs/basic.vim +++ b/vimrcs/basic.vim @@ -206,7 +206,7 @@ vnoremap # :call VisualSelection('', '')?=@/ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Map to / (search) and Ctrl- to ? (backwards search) map / -map ? +map ? " Disable highlight when is pressed map :noh @@ -241,7 +241,7 @@ au TabLeave * let g:lasttab = tabpagenr() " Opens a new tab with the current buffer's path " Super useful when editing files in the same directory -map te :tabedit =expand("%:p:h")/ +map te :tabedit =expand("%:p:h")/ " Switch CWD to the directory of the open buffer map cd :cd %:p:h:pwd diff --git a/vimrcs/extended.vim b/vimrcs/extended.vim index ee8789d5..5df62308 100644 --- a/vimrcs/extended.vim +++ b/vimrcs/extended.vim @@ -99,7 +99,7 @@ inoremap $e ""i """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => General abbreviations """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -iab xdate =strftime("%d/%m/%y %H:%M:%S") +iab xdate =strftime("%d/%m/%y %H:%M:%S") """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/vimrcs/filetypes.vim b/vimrcs/filetypes.vim index 33768bdf..a4e17cbd 100644 --- a/vimrcs/filetypes.vim +++ b/vimrcs/filetypes.vim @@ -26,8 +26,8 @@ au FileType javascript call JavaScriptFold() au FileType javascript setl fen au FileType javascript setl nocindent -au FileType javascript imap $log();hi -au FileType javascript imap alert();hi +au FileType javascript imap $log();hi +au FileType javascript imap alert();hi au FileType javascript inoremap $r return au FileType javascript inoremap $f // --- PHFP2xi diff --git a/vimrcs/plugins_config.vim b/vimrcs/plugins_config.vim index 9f7d56ee..3ca2c6f6 100644 --- a/vimrcs/plugins_config.vim +++ b/vimrcs/plugins_config.vim @@ -14,6 +14,7 @@ call pathogen#infect(s:vim_runtime.'/sources_non_forked/{}') call pathogen#infect(s:vim_runtime.'/my_plugins/{}') call pathogen#helptags() + """""""""""""""""""""""""""""" " => bufExplorer plugin """""""""""""""""""""""""""""" @@ -36,8 +37,8 @@ map f :MRU """""""""""""""""""""""""""""" let g:yankstack_yank_keys = ['y', 'd'] -nmap yankstack_substitute_older_paste -nmap yankstack_substitute_newer_paste +nmap yankstack_substitute_older_paste +nmap yankstack_substitute_newer_paste """""""""""""""""""""""""""""" @@ -45,9 +46,9 @@ nmap yankstack_substitute_newer_paste """""""""""""""""""""""""""""" let g:ctrlp_working_path_mode = 0 -let g:ctrlp_map = '' +let g:ctrlp_map = '' map j :CtrlP -map :CtrlPBuffer +map :CtrlPBuffer let g:ctrlp_max_height = 20 let g:ctrlp_custom_ignore = 'node_modules\|^\.DS_Store\|^\.git\|^\.coffee' @@ -63,8 +64,8 @@ let g:user_zen_mode='a' """""""""""""""""""""""""""""" " => snipMate (beside support ) """""""""""""""""""""""""""""" -ino =snipMate#TriggerSnippet() -snor i=snipMate#TriggerSnippet() +ino =snipMate#TriggerSnippet() +snor i=snipMate#TriggerSnippet() """""""""""""""""""""""""""""" @@ -143,12 +144,6 @@ let g:goyo_margin_bottom = 2 nnoremap z :Goyo -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Vim-go -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let g:go_fmt_command = "goimports" - - """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Ale (syntax checker and linter) """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""