Vim allows you to run all (or some) of your content through an external program. In this case, we want to use Python to format (i.e. pretty print) our JSON with ‘python -m json.tool’. We an also setup a Vim user defined command to reduce typing (and make it easier to remember).
The Esc key is not a convenient key to hit on the keyboard. While many will recommend you map another key to act as your Esc key, by default you can use Ctrl-[ instead.
I use Junegunn’s Vim plugin vim-easy-align to make it easier to align my code. This plugin does not have a default mapping for aligning the dollar sign ($). Because the plugin is designed to be extensible, I was able to add support for aligning by the dollar sign ($) by adding some lines to my .vimrc file.
Vim has a built-in command to close all windows except the current one (:only), which is nice for focusing on a single buffer. Sometimes I want to cleanup my buffers by closing all of the buffers except for the current one. This custom command is like :only for buffers instead of windows.
I wanted to run the latest development version of Neovim (0.4.0) to use some of the latest features (e.g. the floating window). Unfortunately, my attempts to install it were failing. These are my notes on the problem and how I fixed it.
When using Vim sometimes I want to duplicate a file, however the default file explorer in Vim (netrw) does not handle this well. This is a Vim mapping I created to make duplicating a file easier.
When using Vim you can find your <Leader> by using echo for the value of “mapleader”, however there are some edge cases that make this less than ideal. If “mapleader” is undefined an error is thrown instead of showing the default <Leader>. If “mapleader” is not a visible character (e.g. <Space> or <Tab>), you can not see the value. I use the following command to display <Leader> while working around these edge cases.
I do most of my work in Vim (or Neovim) in tmux inside of iTerm on my Mac. I found my color schemes were being properly applied in Neovim but not in Vim (version 8). Adding two lines to my .vimrc corrected the problem for me.
I was looking for a quick way to reference PHP documentation from within Vim. The PHP Manual Vim Plugin allows me to do just that.
This tweet blew my mind. $ git log | vim -R –Now press <K> on a commit hash. — Luke Diamand (@LukeDiamand) February 21, 2018 I spend a lot of my time in Vim and Git and this is an amazing combination of the two. While I love this command, I think we can do […]