Sunday, September 13, 2009

vim: how to split a line

In vim/gvim, you can join two lines using the J command. So I was wondering if there was a simple command to split a line.

After much searching, I found that there really isn't one, but the replace command r, can do so by placing the cursor on the whitespace you want to split and doing the following:


r[Enter]


where Enter means press the enter key.

This works pretty well for splitting a line without having to enter insert mode.
It's a little tip, but it's the little things in life that make life a little brighter. :) Obviously it has to have whitespace at the point of the split to make this work. Otherwise, going to insert mode is probably faster.

No comments: