Schwartzian transform in shell and vim

A few days ago I had to create list of email addresses sorted on the domainname. All addresses with the same name should clump together. Being a Perl programmer, I quickly wanted to write a Perl script to sort this list of data. Then I tought, why not use Vim to look at the intermediate steps and do it with filtering. The following is the result. :%!perl -pe 'm/\@([-\w]+)\./; $_="$1\#$_";' :%!...

January 26, 2010

Whitespace at end of line

On Coding Horror Jeff wrote about whitespace at the end of lines of code. I hate that as much as the next guy. It seems irrational, but I think it’s not. It has no function and only creates problems on times when you don’t expect them, especially with source code control tools. So I wrote a small piece of Vim script code to highlight the spaces at the end of the line in bright red....

November 9, 2009

Autocomplete contexts and people with GTD in Vimoutliner

I wrote an article about GTD and Vimoutliner. This post adds a few simple things you can do to simplify your edits to the todo.otl file. In Vim it is easy to autocomplete a word or line. You can complete a word by typing the first few characters of the word you want to complete. Then type CTRL-N to complete the word. You can try other words by typing CTRL-N more often....

October 15, 2009

Vim function to replace many spaces with one

At last I have found the function that will replace many spaces with one space. I first wrote a blog post about this in januari of 2007. Then I wrote a blog post about how to enhance this function to move the cursor one position after the inserted space. With an update a day after that, which said that it didn’t work in some instances. Today I’m proud to announce the final and working function that works as it should....

August 5, 2009

Insert the current date and keep it up to date

You would like to add an automatically updated timestamp in your text files. You can do that by adding 6 lines of code to your .vimrc. The following command will call the function LastMod() whenever a buffer of file is written. autocmd BufWritePre,FileWritePre *.html call LastMod() The following function will find all files containing ‘Last modified:’ and replace them with the current date and time. fun LastMod() exe "%g/Last modified: /s/Last modified: ....

July 28, 2009

How to use Vimoutliner checkboxes

Vim outliner is an outliner tool. As the name implies you can write outlines with it, but with this particular one you can also create todo lists. A todo list can be created without much effort. First open your todo file, todo.otl for example. By using the otl extension, Vim outliner will be loaded automatically. Next, type a task you have to do in the future. This could something like write blog post about Vim outliner....

July 27, 2009

Write Twitter drafts in Vim

Not everyone writes drafts for his Twitter posts. It seems silly even to do this. But for the people who don’t think writing drafts is silly (and use Vim), I wrote a few lines of Vim script that will help them keep their lines just short enough. Put these lines in your .vimrc file and start writing. You should change the filename to the name of the file that you write your drafts in....

May 29, 2009

Using ack to check coding conventions

August 30, 2008

Human readable date in vim outliner calender

I created a small Perl program to convert relative dates to absolute dates in the format that I use for my calendar. My current calendar file looks like this. 2008 08 2008-08-12 2008-08-13 09 2008-09-10 ... If I want to add a date and I don’t know the actual numbers, I can use the following program to convert the date. It will also respect the whitespace in front of the text....

August 18, 2008

Vim: Just once space revisited

At the beginning of last year I wrote a weblog entry about how to write a function that removes all space but one in Vim. It didn’t work like I wanted, but now it does. function JustOneSpace() " replace all whitespace around the cursor with a space s/\s*\%#\s*/ /e " search backwards for a space call search(' ', 'be') " move to the first character after the space normal l endfunction nmap <space> :call JustOneSpace()<cr> I added the call to the search() function to move to the space that was substituted....

January 24, 2008