Degrading Gracefully with
vim
(or: how to make your
.vimrc
usable by everyone
and
yourself usable by everyone's
.vimrc
)
## Who Am I? * Andrew Ferrier - Architect, IBM Cloud Garage * Regular daily use of `(neo)vim`: * Markdown * Programming * Configuration * `.vimrc` - 706 commits since 2009 🤯.
## 'Degrade gracefully'? * A philosophy borne from a *lot* of pairing... * Most engineers use others' machines and have others use their machine, so your vim should be instantly usable by them 🚗. * *But* it's useful to sugar your `vim` to make it a bit more pleasant and effective 🏎️.
## Principles * Add tweaks that seamlessly enhance `vim`. * In particular, tweaks that make it easier to *learn* `vim` (🎓). * Avoid tweaks that introduce functionality we *rely* on. * Avoid tweaks that break existing `vim` functionality.
(Do I always follow these rules? No. 😳)
# Without plugins
## Incremental search highlight 🎓 ```vim set hlsearch set inccommand=nosplit " neovim only - use traces.vim for vim ``` Highlights the search and replace actions you are taking interactively as they happen.
## Moving between misspelt words ```vim nmap zg zg]s ``` When you mark a 'misspelt' word as good, your cursor advances to the next misspelt word.
## Indent/dedent more easily ```vim vnoremap <
>gv ``` Keeps visual blocks selected when indenting/dedenting.
# With Plugins
## `fzf.vim` Provides better review of search and command history. ```vim nnoremap q: :History:
nnoremap q/ :History/
```
## `junegunn/vim-peekaboo` 🎓 Shows a pop-out list of register contents when using `"` (normal mode) and `
` (insert mode).
## `machakann/vim-highlightedyank` 🎓 Briefly highlights the area that's just been yanked to visualize the text objects you're using.
## `andymass/vim-matchup` Extends '%' so it does more — matches `if`, `while`, `do`, etc. for ~50 languages.
## `tpope/vim-sleuth` * Automatically infers `shiftwidth`, `smarttab` and `expandtab` (indent with tabs or spaces) for each buffer based on buffer contents. * Follows the 'do no harm' principle.
## `tpope/vim-characterize` * *Overrides* a single key-binding `ga` --- so that it displays more useful and modern information.
Before
After
## `henrik/vim-indexed-search` Shows number of results found after searching and index of search result in the overall file.
## Further information
[www.andrewferrier.com/degrade-gracefully-vim](https://www.andrewferrier.com/degrade-gracefully-vim)
[Some of my `vim` plugins](https://github.com/andrewferrier?utf8=%E2%9C%93&tab=repositories&q=&type=&language=vim+script)
## Outtakes (1/2) * `set clipboard=unnamed,unnamedplus` - Common-sense clipboards for people who aren't die-hard X11 users. * [traces.vim](https://github.com/markonm/traces.vim) - `inccommand` for non-neovim users. * `nnoremap
zz` - when moving back through history, center the screen.
## Outtakes (2/2) * `tpope/vim-sensible` - will set sensible defaults and turn off archaic options. * `tpope/vim-endwise` - inserts `endif` etc., but only when it really makes sense to do so. * `farmergreg/vim-lastplace` - opens files at the last place they were being edited.