Search positioning

When searching with /pattern in vim, the cursor lands at the start of the pattern. This is not always ideal. By adding /e to the end of your search pattern, you can have the cursor land at the end of the search pattern. This can come in handy when you would like to cycle through a number of instance of a search pattern and repeat an edit with the dot operator ..

Continue reading »

Remove trailing whitespace

Does trailing whitespace make your blood boil? Although there are plenty of ways to automatically trim trailing whitespace when committing, or even to hide whitespace in diffs, you can easily trim whitespace in Vim with a simple plugin.

Continue reading »

Write a file with sudo

Ever open your /etc/hosts file in Vim, make a bunch of edits, only to :wq and get that dreaded read only error? There a few easy ways to sudo write a privileged file in Vim.

Continue reading »

Sorting Text

Keeping lists alphabetized is important for organized, maintainable code. Fortunately, Vim has a number of ways to sort lines.

Continue reading »

Code Reformatting

When I wind up with code that is not well formatted, the = command comes in handy. This command runs applies a formatter to your motion or visual selection. So two handy sequences of commands I keep at hand are gg=G and =%. The later takes advantage of the matchit plugin which enhances % to match a broad array of open close blocks like those found in the Ruby programming language.

Continue reading »
Top