Tim Pope has just released a new plugin called Flagship (GitHub: tpope/vim-flagship, License: Vim). It makes customising the status line and tab line much easier, and other plugins can extend it as well. For example, if you've got fugitive.vim installed, then you should see the current Git branch in the status line.

This script isn't quite the same as the airline breed of plugins that use super fancy glyphs to make the status line look like a GUI. But it does integrate well with 'statusline' and makes the tab line saner.

The extension API is great for adding flags, but what if you want to change the core content? For the status line, Vim already provides a perfectly adequate 'statusline' option, and Flagship will use it in constructing its own. Customizing your status line is exactly the same with and without Flagship.

Read More →


Sometimes it's not clear if you should use a macro or a plugin for a common editing task. There are things that I'll instinctively create a macro for (:help complex-repeat), and others that are broad enough to be made into plugins. In those cases it's often best to search for a plugin first.

Here's one such example: Mark Volkmann's vim-js-arrow-function (GitHub: mvolkmann/vim-js-arrow-function). It's a small plugin, but does something broad enough that is safely tucked away in a plugin -- it turns anonymous JavaScript functions into their "fat arrow" equivalents.

In JavaScript you commonly pass anonymous functions to methods, like this:

Read More →

WASD Keyboards Vim Keys

I saw people talking about WASD Keyboards because apparently they now sell Vim layouts. WASD Keyboards sells mechanical keyboards, and part of the order process is a detailed customisation stage. You get all kinds of cool options, like switch type (Cherry Blue, Green, etc.), and even sound dampeners.

If you select the WASD V2 87-Key Custom Mechanical Keyboard, you should see "Vim Black" and "Vim White" under the "Alphanumeric Layout Style" section. Vim Black looks like this:

Read More →

Converting gVim-only Colour Schemes

On reddit/r/vim there's a post about adapting dark colour schemes to transparent terminals. One way to solve this, as suggested by gordin, is to use CSApprox.

CSApprox (GitHub: godlygeek/csapprox) by Matt Wozniski can be used to convert gVim colour schemes to work with 256 colour terminals. Many people now use 256 colour terminals, so if you use CSApprox with schemes that previously looked bad you should see something much closer to the right colours.

Whenever you change colorschemes using the :colorscheme command this script will be executed. It will take the colors that the scheme specified for use in the GUI and use an approximation algorithm to try to gracefully degrade them to the closest color available in your terminal. If you are running in a GUI or if your terminal doesn't support 88 or 256 colors, no changes are made. Also, no changes will be made if the colorscheme seems to have been high color already.

Read More →

Indent Detector

What's the worst culprit for bad indentation that you've ever seen? For me Xcode springs to mind. Maybe Xcode isn't inherently bad, but somehow when I open projects authored with it in Vim I see a ridiculous mix of tabs and spaces that makes no sense. I think it downplays the importance of keeping tab settings the same as the rest of your team. It really makes understanding diffs and pull requests on GitHub a messy process.

I recently found Indent Detector (GitHub: luochen1990/indent-detector.vim, License: MIT) by Luo Chen. It attempts to detect mixed indentation and show a warning on bufEnter and bufWrite. It also tries to switch the indentation settings to match the current style.

The time taken to detect indentation is limited, so opening large files shouldn't lock up Vim. It also keeps quiet when readonly files are opened to avoid showing errors when reading help files.

Read More →

The netrw Style Options

I use netrw a fair bit mainly because of Tim Pope's vinegar.vim plugin. I press - to see a list of files in the current directory, and then navigate around using Vim shortcuts and search. You can open netrw in a similar way without installing vinegar.vim, just type :e . and you'll see a list of files.

The way Vim displays files in this view is actually configurable -- you can press i to toggle through the available view types. This is what the "long" view looks like:

netrw long

Read More →

Set Complete

When in Insert mode, you can trigger completion for a word by using CTRL-P. This cycles forward through the list of matches -- CTRL-N goes backwards. The documentation for the complete (:help 'complete') has options for configuring the behaviour of these commands, and I also wrote about it in Vim 101: Completion Compendium.

I'll show you a few useful things you can do with 'complete'. Let's look at what complete options you've got set in Vim. To see them, type :set complete. I see the following: complete=.,w,b,u,t,i. This breaks down to:

  • .: Scan the current buffer
  • w: Scan buffers from other windows
  • b: Scan buffers from the buffer list
  • u: Scan buffers that have been unloaded from the buffer list
  • t: Tag completion
  • i: Scan the current and included files

You probably instinctively know what Vim is doing when you press CTRL-P -- it shows matches for things that it has "seen" during the current session. But you can actually make it do some pretty cool things that aren't the default settings.

Read More →

Better ga and Characterize.vim

betterga (GitHub: manicmaniac/betterga) by Ryosuke Ito is an extended version of the :ascii command. This command is typically invoked with ga, and shows the ASCII value of the character under the cursor in decimal, hexidecimal, and octal.

Ryosuke's version of ga adds some useful extra information, including unicode details. For example:

  • <a> [LATIN SMALL LETTER A] 97, Hex 0x61, Octal 0141
  • <®> [REGISTERED SIGN] 174, Hex 0xae, Octal 0256
  • <∆> [INCREMENT] 8710, Hex 0x2206, Octal 021006

The template is defined with g:betterga_template, so you can change what values get displayed.

Read More →

Vim REST Console

Vim REST Console (GitHub: diepm/vim-rest-console, License: MIT) is a plugin for sending and viewing HTTP requests from RESTful services. It uses cURL, and allows you to type URLs and then get responses back in a separate window.

To make a request, you need to be in a buffer with a file type of "rest": :set ft=rest. Then, type the protocol and hostname on one line, followed by the HTTP method and path on another:

GET /_cat/nodes?v

Once you're ready type the trigger key to make the request, which is C-j by default. The results will be displayed in a split window.

Read More →