Tuesday, January 21, 2014

Generating Mock Userdata

I often find myself needing to generate dummy data when doing software projects. The rig command-line utility makes it easy to do so.
# apt-get install rig

$ rig
Maureen Cummings
614 Spring County Blvd
Phoenix, AZ  85026
(602) xxx-xxxx

Tuesday, January 14, 2014

Removing Lines that Don't Match a Pattern

Following up on a previous tip, you can also use the "g" and "d" commands to remove lines in your current buffer that don't match a specific pattern. The following example would remove all lines that don't match "www.example.com".
:g!/www\.example\.com/d

Monday, January 6, 2014

Finding and Replacing Unicode Characters

If you'd like to find a particular multibyte character, you can do the following.
/\%u001c
You can also do a find and replace as you normally would.
%s/\%u001c//g

Thursday, December 19, 2013

Removing Blank Lines

Here's a handy one-liner to remove blank lines from a file.
:g/^$/d
Breaking this down. The "g" will execute a command on lines that match a regular expression. The regular expression matches blank lines, and the command is "d" (delete).

Friday, December 13, 2013

Vim.js

I'm not sure what utility this provides, but it's a pretty darn cool hack. Kudos to Lu Wang for this Javascript port of Vim. http://coolwanglu.github.io/vim.js/web/vim.html

Monday, November 11, 2013

Snipmate

If you like Textmate Snippits, consider installing Snipmate. From the Github page.

SnipMate aims to provide support for textual snippets, similar to TextMate or other Vim plugins like UltiSnips. For example, in C, typing for<tab> could be expanded to:
for (i = 0; i < count; i++) {
    /* code */
}
The project linked above appears to be a fork of the original plugin, but it's up to date, and it works!

Friday, November 8, 2013

Supertab

If you like Bash auto-completion, you'll love Supertab. Installation and configuration details are available via its Github Page.