My history with ViM
Since the beginning of this website, I have a backlog of my next logs (which is becoming smaller and smaller). That's one of the reason Polysemy update log was published some weeks after its release.
But today, I don't feel like it. As some may know, Bram Moolenaar passed away 3 days ago, I'm still shocked as he wasn't particularly old (61-62) and I didn't remind his health issue announcement. Last time I felt this was learning Dennis Richie death, I still remember, me sitting in my Engineering School's auditorium, few minutes before the lecture began. Anyway, I won't be sentimental much longer.
Even though I didn't know Bram Moolenaar, but I used ViM (not NeoViM) for most of my career (actually, my vimrc
is dated from 2014, but I started playing with it since 2008-2009).
It means that I played around with more or less 30 languages, with the same editor.
To be transparent, I use to used Eclipse/IntelliJ for Java/Scala, Visual Studio for .NET, and VS Code for mob programming.
My vimrc
is quite messy, but I'll try to break it down:
I use vim-fugitive
to deal with git
(mostly grep
, diff
, log
, blame
), I have few shortcuts to navigate through chunks:
nmap >C [n
nmap <c ]n
nmap dgu :diffg RE
nmap dgb :diffg BA
nmap dgl :diffg LO
More broadly for Ggrep
, which populate my quickfix buffer, I can circle through it thanks to:
" QuickFix
nmap <n <Plug>(qf_qf_next)
nmap >N <Plug>(qf_qf_previous)
nmap <f :cnfile<CR>
nmap >F :cpfile<CR>
nmap <l <Plug>(qf_qf_toggle)
nmap >L <Plug>(qf_qf_toggle)
I have few shortcurts to avoid INSERT
mode.
Here are some of them to move lines vertically and horizontally:
" Moving indentation
nmap gV `[v`]
nmap <Tab> >>
nmap <S-Tab> <<
vmap <Tab> >gv
vmap <S-Tab> <gv
" vim-easy-align
vmap A <Plug>(EasyAlign)
nmap gA <Plug>(EasyAlign)
" unimpaired
" Move one line vertically
nmap <C-Up> [e
nmap <C-Down> ]e
" Move multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
The other type of change is to circle through alternatives:
" vim-abolish (change case, camelCase, UP_CASE, snake_case, kebab-case)
map crl guaW
" vim-swap (move arguments and structure position)
let g:swap_no_default_key_mappings = 1
nmap <C-Left> <Plug>(swap-prev)
nmap <C-Right> <Plug>(swap-next)
" Switch between alternative language elements (i.e. True/False)
nnoremap - :Switch<CR>
autocmd FileType haskell let b:switch_custom_definitions =
\ [
\ ['Right', 'Left', 'Just', 'Nothing'],
\ ['Maybe', 'Either'],
\ ['then', 'else'],
\ ['all', 'any', 'allM', 'anyM'],
\ ['when', 'unless', 'whenM', 'unlessM'],
\ {
\ '^\(\s*\)let \([^=]*\) =': '\1\2 <-',
\ '^\(\s*\) \([^=]*\) =': '\1let \2 =',
\ '^\(\s*\)\([^=]*\) <-': '\1let \2 =',
\ '': ''
\ }
\ ]
I also have few tricks to select formatters (based on neoformat
) through environment variables (which are based on my projects' direnv
configuration):
let g:neoformat_enabled_nix = ['nixpkgsfmt']
if exists("$WITH_NIXFMT_CMD")
let g:neoformat_enabled_nix = [expand("$WITH_NIXFMT_CMD")]
endif
Overall, ViM thought me to take a step back on my daily practice, find what's work, what does not, and improve what does not. It tought me that composition is the key to build robust thing, either in software or in engineering.
For reference, here's my plugins list:
" syntax
Plug 'tweekmonster/startuptime.vim'
Plug 'tpope/vim-markdown'
Plug 'hspec/hspec.vim'
Plug 'blackheaven/vim2hs'
Plug 'elzr/vim-json'
Plug 'Shougo/unite.vim'
Plug 'kongo2002/fsharp-vim'
Plug 'AndrewRadev/inline_edit.vim'
Plug 'sbdchd/neoformat'
Plug 'hashivim/vim-terraform'
Plug 'dense-analysis/ale'
Plug 'sdiehl/vim-ormolu'
Plug 'mpickering/hlint-refactor-vim'
Plug 'LnL7/vim-nix'
Plug 'bazelbuild/vim-ft-bzl'
Plug 'neoclide/coc.nvim'
Plug 'purescript-contrib/purescript-vim'
Plug 'vmchale/dhall-vim'
Plug 'dhruvasagar/vim-dotoo'
Plug 'Shougo/denite.nvim'
Plug 'rhysd/vim-grammarous'
" textobj/move
Plug 'tpope/vim-surround'
Plug 'Lokaltog/vim-easymotion'
Plug 'wellle/targets.vim'
Plug 'kana/vim-textobj-user'
Plug 'glts/vim-textobj-comment'
Plug 'vimtaku/vim-textobj-keyvalue'
Plug 'sgur/vim-textobj-parameter'
Plug 'machakann/vim-textobj-functioncall'
Plug 'thalesmello/vim-textobj-methodcall'
Plug 'blackheaven/vim-textobj-function'
Plug 'vim-scripts/ReplaceWithRegister'
Plug 'jpalardy/vim-slime'
Plug 'christianrondeau/vim-base64'
Plug 'wellle/tmux-complete.vim'
" visual
Plug 'Yggdroot/indentLine'
Plug 'ivyl/vim-bling'
Plug 'RRethy/vim-illuminate'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'luochen1990/rainbow'
Plug 'sainnhe/gruvbox-material'
" search
Plug 'haya14busa/incsearch.vim'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-abolish'
Plug 'romainl/vim-qf'
" vcs
Plug 'tpope/vim-fugitive'
Plug 'mhinz/vim-signify'
Plug 'Yggdroot/LeaderF'
Plug 'skywind3000/Leaderf-snippet'
" commands/codegen
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-endwise'
Plug 'machakann/vim-swap'
Plug 'AndrewRadev/switch.vim'
Plug 'junegunn/vim-easy-align'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'kana/vim-smartinput'
Plug 'mbbill/undotree'
Plug 'tpope/vim-repeat'
Plug 'kopischke/vim-fetch'
Plug 'drmikehenry/vim-fixkey'
Plug 'editorconfig/editorconfig-vim'
Plug 'octref/RootIgnore'
Plug 'chrisbra/NrrwRgn'
Plug 'sotte/presenting.vim'
Plug 'triglav/vim-visual-increment'
Plug 'blackheaven/vim-ghcid'