Vim is about precision editing at the speed of thought. Vim is also about quickly navigating a project to find and read old code.
Indeed, the ratio of time spent reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code. …[Therefore,] making it easy to read makes it easier to write.
― Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship
NeoVim is a modern drop-in replacement for Vim. In fact it is easy to share a Vim config with NeoVim via a symlink, but there are some caveats which are outside the scope of this article.
Note: Syntax highlighting and color may not work as expected within Tmux until it is configured in Part 4 correctly.
There’s a certain magic to writing your editor config with that very same editor. I suggest handwriting these configs so you can learn as you type.
<Leader> key is what is pressed before another key to activate some command via a shortcut. By default Vim uses the rather awkward key
\. Many respected Vim users choose
<Space> as their leader key instead and I agree with this change.
These dotfiles are going to rock this world so hard we don’t need mice where we’re going. Keep those hands on the keyboard and power on.
This was the config best decision I ever made. Relying on arrow keys results in less efficient code editing. Should you find this frustrating, turn those frustrations into learning experiences to find the quickest way to have the cursor reach the target.
Space Spaceto open previously opened file buffer
Tabto switch to next buffer
Shift Tabto switch to previous buffer
This keybinding becomes more intuitive after installing the plugin suggested below to convert buffers to onscreen tabs with vim-airline.
Stock, even heavily configured, Vim is lacking features offered by other GUI applications. While the objective is not to convert Vim into something it isn’t it is essential to implement some missing functionality through plugins.
There are several plugin managers out there but vim-plug is the most minimal while being fast in uptime and concurrent plugin installation.
call plug#begin and
call plug#end insert the keyword
Plug followed by the path to the plugin in Github such as
Plug 'username/project. See further examples in the suggested plugins below.
After adding a
Plug and saving the vimrc file run the install command by hitting colon followed by
As stated earlier, Vim is not a GUI. Unite is a commonly used resource for plugins to open panels and other temporary interfaces onscreen. Unite is required for many plugins to work as expected.
Dracula is dark yet vibrant, needs no additional configuration, and is supported in a wide variety of apps for a consistent experience.
Indentation guides provide a subconcious way of understanding how your code fits together horizontally as well as assuring that indentation is correct at a glance.
As code is added, modified, or removed a visual aid will be placed alongside the number gutter. gitgutter takes advantage of NeoVim’s async capabilities to never slow you down.
Programming in vim can abstract away much of what’s happening behind the scenes. In many ways, this is great — but visual reminders are useful for making day-to-day programming a nobrainer.
vim-airline is widely popular, and surprisingly beautiful, without making vim look too much like a GUI. This plugin and config will show current mode, current file path, % scrolled through file, tabs for current buffers, and more.
It automatically works with plugins it recognizes, such as CtrlP! (Which we’ll install next…)
The quickest way to jump to a file in your project is with a fuzzy finder. Similar experiences can be found in popular code editors like Atom.io or Sublime. With vim the same experience can be achieved at lightning speeds when paired with Ag and NeoVim. I’ve tried other fuzzy finders like fzf, but have found ctrlp to have the best experience and most reliable.
Space popens Fuzzy Finder
Sometimes you just need to find some text somewhere in your project. The Silver Searcher, also known as Ag does just this and it does so very quickly. Grepper uses Ag’s speed combined with NeoVim’s async abilities to provide a fast way to find code anywhere in your project or buffers.
Space f pto type a search to find matches in entire project
Space f bto type a search to find matches in current buffers
While not my preferred way to navigate a project, it’s handy to have a file tree to see directory structure and browse for a file manually.
Space backtickto toggle File Tree
Space ~to open File Tree from current buffer’s directory
A pretty standard feature of many code editors, an async dropdown tabbable suggestion menu as you type.
Async as you type code linting at its finest. Zero config needed.
The secret to never needing to
wwwww, or worse
lllll is learning how to Sneak around your code. Efficient targeting comes from understanding where you want to jump to and pressing the appropriate sneak keys to get there. Key bindings listed below.
f <key>to jump to next
F <key>to jump to previous
fto following match
s <key><key>to jump to next
S <key><key>to jump to previous
sto following match
The web is a very diverse space. I suggest searching VimAwesome for the languages you program in most often to find what plugins may assist you personally.
Part 3 will cover configuring Zsh.A Modern Terminal Workflow — Part 3 / 5