Script Roundup: Projections.vim, Unstack.vim

Projections.vim

If you like Rails.vim then you might be interested in Projections.vim (GitHub: malkomalko / projections.vim, License: Vim) by Robert Malko. It brings the workflow ideas from Rails.vim to other languages by using a JSON file to map between a target language and the MVC style of development used by Rails.

It's mostly useful as a project navigation tool: if you want to open a model file then :Emodels model will work. The prefix, E, can be changed to open in a split (S) or tab (T).

Files can be created based on templates. The templates are just strings in the configuration file, so a model for a JavaScript project might be module.exports = function() {\n};\n.

Read More →

Easier Undo Traversal

After making a lot of speculative changes in a file which didn't work out, I find myself undoing and redoing changes in quick succession. It's easy to get lost in the undo tree, and Vim doesn't have any built-in features for easily seeing what each change in :undolist looks like.

There are plugins that can help, like undotree.vim, but one small change I made in my workflow was to learn the g+ and g- shortcuts. All these Normal mode shortcuts do is go to the newer or older state. A count can be used as well, but I usually find myself looking at each change until I find the one I want.

If you haven't yet mastered :undolist or Vim's time/tree-based undo system, take a look at Vim 101: Undo.

Read More →

Script Roundup: vim-emoji, fontdetect

vim-emoji

Vim emoji

If you're using a Mac, you're probably familiar with emoji. vim-emoji (GitHub: junegunn / vim-emoji) by Junegunn Choi makes it easier to work with emoji in Vim. The author's examples include settings for Git Gutter.

The plugin provides a function that can be used to look up an emoji symbol, like this: emoji#for('small_blue_diamond'). That means you could tie it into anything you want: perhaps a :boom: for FIXME comments...

Read More →

Vim: Do Repeat Yourself

Do yourself a favour: learn how and what you can repeat in Vim. I'm tired of people looking at me like I'm a wizard when I make an edit and repeat it a bunch of times with .. This happens a lot with document types that are naturally repetitive -- HTML for example.

It's easy to get the hang of. Let's say you've got this:

<p>This is a story all about how,</p>
<p>My life got flipped, turned upside down,
<p>And I'd like to take a minute just sit right there,</p>
<p>I'll tell you all about why my Vim skills are rare

If I typed </p> and then pressed . at the end of the second line, it would add a paragraph tag. You can keep pressing . wherever needed.

Read More →

Vim Help PDF

In Reproducing Vim help as a fully cross-referenced PDF, Nathan Grigg talks about a project he embarked on to create a cross-referenced PDF of Vim's documentation:

It's a long story, but for the last six months, I have been using Vim as my primary text editor. As I began to use Vim more often, I was frustrated by the lack of a tutorial that went beyond the basics. I finally found what I was looking for in Steve Losh's Learn Vimscript the Hard Way, which is an excellent introduction to Vim's power features. I also discovered the real reason there are no advanced tutorials, which is that everything you need to know is contained in Vim's help files.

One of the goals was an iPad-friendly PDF. He used Latex, and eventually ended up with an 11-megabyte, 2500-page PDF, which actually reads quite nicely.

Read More →

Script Roundup: DuplicateWrite, SuperSub

DuplicateWrite

DuplicateWrite by Ingo Karkat is a script that writes a duplicate copy of a file whenever it's saved. That means you could do things like use netrw to write a copy to a remote server.

This plugin defines a :DuplicateWrite command that sets up additional :write targets. From then on, whenever you save that buffer, the write is cascaded to the additional files. Thus, when editing a script in your project directory, you can have it immediately copied to the install directory that is in the PATH. Or, with the help of the netrw plugin, you can even automatically upload a locally edited HTML page to the remote web server.

The author notes that version control and automated deployment make this largely redundant, but there are times when it might be convenient.

Read More →

Popular Dotfile Options

I loves a bit of dotfile spelunkin':

I downloaded 155 .vimrc files from the net (mostly from dotfiles.org and github.com), and wrote a little script which counts the number of times an option has been set. Since most options come in normal- and shortcut form, I mapped the shortcuts to the long version whenever I recognized them.

Comparing the popular options against your own .vimrc may yield useful insights. For example, I noticed I don't use the following:

Read More →

Vim for Erlang Development

How to use Vim for Erlang Development by Martin J. Logan, who wrote Erlang and OTP in Action, introduces a familiar cocktail of Vim scripts tailored for Erlang development.

If you read on towards the end, however, there are some good tips based on the author's workflow. I liked this tip about using marks to indent awkward sections:

vimerl will auto-indent for you as you type. But if you come across a line that you want to indent try typing ==. Let's say you want to indent a block of code. Simple, mark the line that starts the block with ma then go to the end of the block and tell vimerl to indent to the mark as such: ='a. Now if your whole file is a mess then try gg to go to the beginning of your file and then =G to indent all the way to the end. You can do this all in one step as in gg=G.

Read More →

Script Roundup: Stop Sign, KillBrackets

Stop Sign

Stop Sign (GitHub: joshuarh / vim-stopsign, License: Vim) by Joshua Hoff is a small plugin for integrating with command-line debuggers. If you type dbg it will expand to the current file type's debug invocation code.

In languages like Ruby this is done with inline code, so Stop Sign makes this process a little bit more convenient.

KillBrackets

KillBrackets (License: MIT) by Jonas Møller is designed to quickly remove matching brackets. It works for Lisp, but could technically be used in other languages with a bit of configuration:

Read More →