Script Roundup: jdaddy.vim, wildfire.vim

jdaddy.vim

jdaddy.vim (GitHub: tpope / vim-jdaddy, License: MIT) by Tim Pope is a set of useful mappings for working with JSON.

aj is a text object for the outermost JSON object, and gqaj pretty prints the JSON under the cursor. There's also gwaj, which merges JSON from a register into the outermost JSON object.

There are more features that are documented in doc/jdaddy.txt. The source itself is interesting -- there's a parse function that uses some monster regular expressions.

Read More →

A Tale of Two Selections

One command that's burned into my muscle memory is gv. This starts Visual mode with the previous area selected. I find this useful for shuffling around blocks of text or applying commands to selected regions. Some commands clear a region, so quickly typing gv to get it back is great.

There are arguments to avoid Visual mode for certain classes of operations, but I find it useful for performing refactoring, or stylistic changes. Practice gv if you're not used to it.

I often want to do the opposite as well: after putting (pasting) something I may want to visually select it. This isn't as easy as gv, and it took me a while to figure it out -- `[v`]. It works like this:

Read More →

Hidden Documentation

Mislav Marohnić wrote Every line of code is always documented, an article about figuring out the reasoning behind confusing code:

As it turns out, this line--more specifically, the change which introduced this line--is heavily documented with information about why it was necessary, why did the previous approach (referred to by a commit SHA) not work, which browsers are affected, and a link for further reading.

He gives some examples with Vim and Fugitive, detailing the exact keystrokes needed to use :Gblame to compare buffers against files on GitHub.

Read More →

Script Roundup: Better Whitespace, vim-stdtabs

Better Whitespace

I spent ages fiddling with my vimrc to get whitespace displayed just the way I wanted. It was awkward because some of the UTF-8 symbols I wanted to use didn't reproduce properly on all of the terminals and systems that I use. A time saving alternative might have been Better Whitespace (GitHub: ntpeters / vim-better-whitespace) by Nate Peterson, a plugin for highlighting trailing whitespace.

Whitespace for the current line will not be highlighted while in insert mode. It is possible to disable current line highlighting while in other modes as well (see options below). A helper function :StripWhitespace is also provided to make whitespace cleaning painless.

Once it's installed you can toggle whitespace with :ToggleWhitespace, or even just toggle the current line with :CurrentLineWhitespaceOff.

Read More →

Vimtronner

Vimtronner

Vimtronner from Carbon Five is an online multiplayer game for learning Vim. It requires Node, and the controls are entirely based around Vim's commands.

You can start a game by pressing i, and the movement keys are hjkl. It's run as a command-line tool which accepts switches for things like listing games, and running a local server.

Read More →

MacVimFramework

Here's an interesting project for Objective-C developers: MacVimFramework, a fork of MacVim that allows you to use a MacVim view in your own applications. To use it, you'll need to link against PSMTabBarControl.framework and MacVimFramework.framework.

There's an example of how to use it: MMAppDelegate.m. The author Tae Won Ha, notes the framework isn't necessarily a well-designed Objective-C framework, but the embedded source from Vim has minimal changes.

Read More →

Script Roundup: blockit, Enchanted Vim

blockit

blockit (GitHub: sk1418 / blockit, License: MIT) by Kent Yuan allows you to wrap text in horizontal or vertical blocks. You can specify characters to use for the vertical and horizontal replacements, so you could easily wrap a region with - and | characters to make a box.

The readme has examples with animated gifs so it's easy to see how it works.

Enchanted Vim

Enchanted Vim by Marcin Szamotulski makes regular expressions behave as if \v had been used. You might like this if you need to search with brackets a lot and find the escaping difficult, but check :help magic to be clear about the implications of \v and \m.

Read More →

Making JavaScript Strings

Vim Stringify

When I was at Vim London on Tuesday, Jack Franklin gave a talk about writing plugins. He said that when you find things you can automate, you feel like you've given yourself superpowers.

Vim-stringify (GitHub: 29decibel / vim-stringify, License: GPL) is a good example of such a plugin, because it helps deal with something I hate about JavaScript: the lack of multiline string support. If you're crafting HTML fragments, or SQL statements, pasting them into a JavaScript file requires an annoying extra step. You have to wrap each line with a quote, and use concatenation to join the strings:

Read More →

Vim and the Web, Vim Croquet

I spoke at Vim London last night about Vim and the web. The slides are here: Vim and the Web, and the Lanyrd page has more resources and coverage.

I've spent some time with Chromebooks over the last year, trying to use web-based editors. Some attempt to emulate Vim, which is never quite 100%. Recently the Vim.js project caught my attention -- it uses Emscripten to build a JavaScript version of Vim that has asm.js optimisations. I cover this briefly in the talk.

Vim Croquet

Seth Brown's Vim Croquet post discusses analysing keystrokes in Vim. He generates a heatmap based on thousands of keystrokes and finds ways to improve his editing fluency.

Read More →

Script Roundup: Vader.vim, Textabyss

Vader.vim

Vader.vim is a unit testing framework for Vim scripts. It has a BDD style syntax (Do, Given, Expect), and tests are run with the Vader command.

Test file should have the .vader extension. You can split tests into multiple files by using Include. The author has included examples of Vader being used to test real-world projects, including vim-sneak.

Textabyss

Textabyss by Liang Li is a plugin for panning around lots of files. It organises files into columns, and allows you to scroll through columns quickly using the mouse. It's a unique idea that's best explained in a video.

Read More →