I’ve been trying to switch to Vim from TextMate as my default text editor, and I’m constantly stumbling and learning in the process.

One quirk I dealt with recently was spaces. Well, yeah, spaces.

I liked using Monaco as my default font on TextMate and Xcode when I’m working on Python scripts or on iOS apps, mainly because characters are distinct, and it is difficult to confuse 0 (figure zero) and O (uppercase O), or 1 (figure one) | (Vertical bar) I (uppercase i) and l (lowercase l) – which are all characters that occur a lot in programming. So I wanted to set it up as my default font on GVim on Ubuntu. I got a copy of it and installed it just fine, and set it as my font on GVim using the menu.

To make it my default font, I went ahead and opened my .vimrc file, and when I looked it up on GVim (using set guifont?), I saw this:

guifont = Monaco 11

:set guifont?

Then I added the same line to my .vimrc as

MonacoVimrcNoSpace

Incorrect vimrc settings

and it wouldn’t work. Whenever I started GVim, it would complain that it didn’t understand the .vimrc file.

After searching online and looking up a lot of forum posts, I learned that Vim does not recognize spaces in arguments. So I actually had to add a backslash (\) after the first word if I wanted vim to treat the next word as part of the same argument.

Monaco\ 11

Correct .vimrc settings

And it worked!

Now I’ve been using it in more places where it’s appropriate. For example, if I have a long piece of text and I wanted to replace apples with yellow oranges, I could just do

:%s/apples/yellow\ oranges/g

and voila, every occurrence  of apples will be replaced with yellow oranges.

Maybe this will help another struggling Vim user someday!

Tagged with:
 

5 Responses to VIM Tip: Spaces in arguments

  1. harry says:

    A better magazine theme would make the blog nicer.:)

  2. Dav says:

    Keeping the colors 100% the same on the colnose is impossible simply because the capabilities aren’t there. A couple of things that might help:- Make sure you’re using a colnose terminal capable of 256 colors; not all of them do (particularly on mac). You might need to explicitly force Vim to use that by doing set t_Co=256 on your .vimrc file.- The windows colnose is well totally unsupported, that only does 16 colors so it’s a mess

  3. heart health says:

    Really fantastic information can be found on this blog.

  4. Cheers, I just stopped by to visit your site and thought I’d say I enjoyed myself.

  5. Venkat says:

    Never mind I figured it out. For annyoe curious: To get terminal VIM to use your transparent background with this theme, change line 204 s ctermbg from 234 to none. Do the same for line 208 if you don’t want the line numbers to have a background.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>