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

Just one space

I always wondered why vim didn’t have the just-one-spacefunction. It’s one of the most useful functions that is available during coding. So today I tried to write one myself, the newsgroups and searchengines didn’t come up with something good. First of course it is a good idea to understand the effect of this operation. The just-one-space function removes all whitespace around the cursor and replaces it with one space character....

January 25, 2007