vim
Core Functionality (Vocabulary)
-
Cdelete current line (after current cursor position) and enter insert mode -
Ddelete current line (after current cursor position) -
dddelete current line -
ciwdelete the current word -
citdelete between the current html tag -
ci)delete between the () -
- Cursor movement commands (hjkl)
-
- Move by word (w and b) and page (^f and ^b)
-
- Search for word under cursor (forward * and backward #)
-
- File commands (:w, :new)
-
- Split buffer (:split) and buffer movement (^w and hjkl)
-
- Tab commands (:tabnext, :tabnext etc, bound to ",tn", ",n", ",p" etc)
-
- File explorer (:Explore(), bound to ,f)
-
- Move to start and end of file (gg and G)
-
- Switch modes (v, V for linewise, i, esc)
-
- Basic register operations (dd, y, p, P)
-
C- delete until end of line and enter insert mode. -
>iB- increase indentation of current block -
ctrl+]jump to tag definition
Registers
https://stackoverflow.com/questions/1497958/how-do-i-use-vim-registers
Great in depth answer about registers: https://stackoverflow.com/a/3997110
Leader Key(s)
A great explanation of leader keys: https://tuckerchapman.com/2018/06/16/how-to-use-the-vim-leader-key/
Plugin Managers
vim-plug
If vim plug is acting up; force it to download the latest version with: :PlugUpdate! fzf
Plugins
Git
Fugitive
:help fugitive
- Browse historical versions of current file:
:0Gclog
Linting
ALE - Asynchronous Lint Engine
Seems like it requires VIM 8.0 or greater at this point; so install vim from source or use this PPA which seems semi-legit: https://launchpad.net/~jonathonf/+archive/ubuntu/vim
Neomake
Used https://github.com/neomake/neomake but should look into using ALE instead as neomake seems a bit buggy in my experience. Instead, moved to coc.nvim
Tags
See here for good info on how to generate tags: https://github.com/shawncplus/phpcomplete.vim/wiki/Getting-better-tags
It sounds like the original ctags program is abandoned, so it's best to use https://github.com/universal-ctags/ctags or possibly https://github.com/vim-php/phpctags (obviously if you only need PHP tags). Seems like universal-ctags is a fairly active project so it seems like a good option.
universal-ctags
Available as a snap for linux: https://github.com/universal-ctags/ctags-snap though there are some caveats due to security restrictions, including the inability to generate tags for projects outside of the user's home directory.
Compiling from source https://github.com/universal-ctags/ctags/blob/master/docs/autotools.rst instead, since there isn't a good PPA or ubuntu package:
git clone https://github.com/universal-ctags/ctags.git
cd ctags
./autogen.sh
./configure
make
sudo make install
Tips on MacOS
https://gist.github.com/nazgob/1570678
brew install ctags
Update - better yet; use universal-ctags:
brew install universal-ctags
Which leads to:
/opt/homebrew/bin/ctags --version
Universal Ctags 6.2.0, Copyright (C) 2015-2025 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Jun 12 2025, 22:31:15
URL: https://ctags.io/
Output version: 1.1
Optional compiled features: +wildcards, +regex, +gnulib_fnmatch, +gnulib_regex, +iconv, +option-directory, +xpath, +json, +interactive, +yaml, +case-insensitive-filenames, +packcc, +optscript, +pcre2
Unfortunately xcode command line tools installs a conflicting older/worse ctags in /usr/bin/ctags that may have precedence on the system. To fix, make sure homebrew's intall directory is prioritized in your PATH.
vim-gutentags
Automatically regenerate tag files with https://github.com/ludovicchabant/vim-gutentags
Snippets
https://github.com/SirVer/ultisnips
Autocomplete
coc.nvim / coc.vim
https://github.com/neoclide/coc.nvim
:CocInfo to debug
:CocInstall coc-phpls for php language server
List of extensions and extension docs: https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions
coc-php-cs-fixer
PHP CS Fixer via coc-php-cs-fixer
Customize settings via adding entries to :CocConfig file, ex.:
php-cs-fixer.terminal.enableSplitRight
and run with:
:CocCommand php-cs-fixer.dryRunDiff
:CocCommand php-cs-fixer.fix
Snippets Support:
:CocInstall coc-snippets
Discussion about setup for PHP / Laravel: https://github.com/neoclide/coc.nvim/issues/590
phpcomplete
https://github.com/shawncplus/phpcomplete.vim
Useful to install supertab which maps tab to the control-x + control-o hotkey that triggers omnicomplete, in a way that is compatible with snippets. Good article here on setup: https://jordaneldredge.com/blog/setting-up-php-completion-in-vim/
phpcd
Maybe a better version of phpcomplete: https://github.com/lvht/phpcd.vim
Enhanced Statusline Options
lightline
https://github.com/itchyny/lightline.vim seems like a good option.
lightline color schemes: https://github.com/itchyny/lightline.vim/blob/master/colorscheme.md
Misc.
vim-markdown
https://github.com/preservim/vim-markdown
Install it just for the :Toc command, which brings up a sidebar table of contents for the current markdown document.
Generate a table of contents and insert into document: :InsertToc
Config entries for .vimrc:
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_frontmatter = 1
surround.vim Plugin
Commands
ds'delete the surrounding single quotescs'"changing the surrounding single quote for double quote/incremental searcho/Oinserting new linesyssadd surrounding character(s) to current line
Resources
PHP-Indenting-for-VIm
Official PHP indentation plugin for VIm: https://github.com/2072/PHP-Indenting-for-VIm
:help php-indent
investigate.vim
https://github.com/keith/investigate.vim - cool plugin that launches various docs for the keyword under the cursor
Defaults to gK
eunuch.vim
Vim wrapper for UNIX shell commands:
:Delete: Delete a buffer and the file on disk simultaneously.:Unlink: Like:Delete, but keeps the now empty buffer.:Move: Rename a buffer and the file on disk simultaneously.:Rename: Like:Move, but relative to the current file's containing directory.:Chmod: Change the permissions of the current file.:Mkdir: Create a directory, defaulting to the parent of the current file.:Cfind: Runfindand load the results into the quickfix list.:Clocate: Runlocateand load the results into the quickfix list.:Lfind/:Llocate: Like above, but use the location list.:Wall: Write every open window:SudoWrite: Write a privileged file withsudo.:SudoEdit: Edit a privileged file withsudo.- File type detection for
sudo -eis based on original file name. - New files created with a shebang line are automatically made executable.
Guides
- https://robertbasic.com/blog/current-vim-setup-for-php-development/
- https://statico.github.io/vim3.html
- https://thevaluable.dev/vim-php-ide/
Notable .vimrc Examples
Misc. Resources
- https://www.vi-improved.org/vim-proverbs/
- https://romainl.github.io/the-patient-vimmer/
- https://www.vi-improved.org/help-with-help/
- https://www.vi-improved.org/recommendations/
- good simple cheatsheet: http://fprintf.net/vimCheatSheet.html
- attempt at a graphical cheatsheet: http://www.viemu.com/vi-vim-cheat-sheet.gif
- attempt at a graphical cheatsheet: http://michael.peopleofhonoronly.com/vim/vim_cheat_sheet_for_programmers_screen.pdf
- a good text cheatsheet: http://vimsheet.com/ and advanced: http://vimsheet.com/advanced.html
- An interesting "out-of-the-box" vim setup including some common plugins and features (looks a bit neglected / out of date): https://github.com/carlhuda/janus
Comments