Taming Vim's Limits

Vim has a handy command-line option for opening files in multiple windows: -p. If I wanted to open all of the tests in a JavaScript project, I could type vim -p test/**/*_test.js, and Vim would dutifully open each file. But what if there are dozens of files? Fortunately, Vim guards against this with 'tabpagemax'. You can use set tabpagemax= to change the limit in your .vimrc.

Also, the number of undo levels is limited by 'undolevels'. You can change this if you don't mind using more memory, or set it to 0 for one level of undo.

Vim has other limits. If your system uses 32 bit long integers, then the largest a file or line can be is 2,147,483,647 characters. I think that's about two gigabytes. It's also the eighth Mersenne prime. To put this into perspective, Jacob's Room by Virginia Woolf on Project Gutenberg is 340062 characters. A single text file in Vim could contain all of Woolf's work, as well as Hemingway, Joyce, and Kafka.

Read More →


Crunch (GitHub: arecarn / crunch) by Ryan Carney is a plugin for performing calculations. Typing :Crunch <args> will evaluate a mathematical expression, and :Crunch displays a prompt. :CrunchLine calculates expressions on the current line, and this also works with visual selections. :CrunchBlock works on paragraphs.

The supported expressions are easier to write than the default mathematical syntax. For example, you can use 2sin(1) instead of 2*sin(1), and it has implicit integer to float conversion. If you're in Normal mode and type "=1/2<Enter>p you should see 0 inserted, while "=1.0/2.0<Enter>p would have printed 0.5. With Crunch you can just type :Crunch 1/2.

I was looking at the tests for the project, and I believe Ryan has used VimTAP (GitHub: vim-scripts / VimTAP), which is a Vim script that implements the Test Anything Protocol:

Read More →

Script Roundup: Vim Processing 1.0, vim-gnote

Vim Processing 1.0

Vim Processing has been updated to version 1.0. It has the following new features:

  • Compile and run processing sketches with :make, and full integration with the QuickFix window and Vim compiler directives
  • Syntax updates for Processing 2.0
  • Scripts to autogenerate syntax files for those using development versions of processing, or custom variants
  • Full help documentation

The main features provided by the plugin are syntax highlighting, documentation, and integration with Vim's compiler support.


vim-gnote (GitHub: Zuckonit / vim-gnote, License: MIT) uses Python to store notes in an IMAP mailbox. To use it, set your username and password with g:gnote_mail_username and g:gnote_mail_password, then store files as notes with the Gnote() function. The author recommends using this mapping:

Read More →

Increasing Vim's Command History

If you type :set history, you'll see the number of : entires that will be stored. The default is 20, which is what my Vim is set to. However, you can easily set it to anything: I've seen vimrc files on GitHub with it set to 10000.

History includes previous search patterns as well as command-line entries. These are written to the .viminfo file. You can change which file Vim reads for .viminfo by using the -i switch when starting Vim, and if you use -i NONE you can start Vim without a viminfo file, which can be useful if you're trying to work out strange behaviour between sessions, or if Vim is starting up slowly.

These days disks are fast enough that a large viminfo shouldn't cause much of a slowdown, so you may find it useful to increase 'history' beyond the default of 20.

Read More →

More Instantly Better Vim

Vim Star Wars crawl

I found More Instantly Better Vim on O'Reilly's programming blog. It's a talk by Damian Conway with lots of ideas for extending Vim and using it more productively.

The post on O'Reilly's blog has links to each section of the talk. There's an amusing part that demonstrates an ASCII art animation inspired by the Star Wars crawl in Vim, and you can download this and all the other code here: http://is.gd/IBV2013.

Read More →

Script Roundup: Cosco.vim, vim-airline-tomato


Cosco.vim (GitHub: lfilho / cosco.vim, License: MIT) by Luiz Gonzaga dos Santos Filho automatically inserts semicolons in Vim. It appends, substitutes, or removes commas or a semicolons based on context.

It's designed with JavaScript in mind, but the author notes it should work with any language. It adds a function called cosco#commaOrSemiColon, so it can be set up to trigger when , or ; is pressed.

Interestingly, this plugin includes unit tests written with vim-unittest.

Read More →

Protect Notes with Vim Encryption

Vim encryption

Did you know Vim has built-in encryption? All you need to do to use it is to master the single command :X.

When you've got an open buffer, before saving type :X in Normal mode. Vim will prompt you for an encryption key twice. Then you can save the file with :w.

Read More →

MacVim Updated for Mavericks


Björn Winckler has released MacVim builds for Mac OS 10.9 (Mavericks): https://github.com/b4winckler/macvim/releases. Mavericks is a free upgrade, and as usual Björn won't be maintaining MacVim for previous releases of Mac OS.

Since I've upgraded my Mac to OS X 10.9 I will from now only be maintaining binaries for this version of OS X. If anybody wants to provide binaries for OS X 10.6 (which I used to build for) then please let me know.

Read More →

Script Roundup: mlessnau_block_shift, JavaScript Context Coloring


mlessnau_block_shift is a small but well-formed plugin for selecting blocks of text and shifting the block up or down.

When in Visual mode, pressing <C-K> will move the selection up, and <C-j> will move it down. The corresponding functions are BlockShiftUp and BlockShiftDown, so you can rebind them if needed.

JavaScript Context Coloring

JavaScript Context Coloring (GitHub: bigfish / vim-js-context-coloring, License: MIT) is a plugin for JavaScript development. It requires Node, and colourises buffers based on scope.

Read More →

Actual Vim in Sublime Text 3

Here's an artefact of such unique strangeness that I had to write about it: Actual Vim. It's a Python script that acts as a bridge between Sublime Text 3 and Vim.

It works like this: a hidden Vim instance is used to manipulate a buffer that Sublime Text is editing. You interact with Sublime Text directly, but are able to use Vim commands, motions, and pretty much everything:

It's not simply a terminal emulator embedded in a text editor. Sublime is still in control of the text buffer. You will be able to use the entire native Sublime interface while in INSERT mode, including plugins.

Read More →