4

I'm trying to set a custom breakat for plain text files. Aiming for a very small set of characters -- just hyphens, slashes, and whitespace. That means I need to add tabs, which I do by setting breakat+=^I. (Right?)

At first, I didn't understand how control characters worked, and appended ^ I to my breakat value. Naturally, as a result, my files started breaking at capital I's. -_-'

So then I went digging, and found this: <C-v> followed by any control key should produce the literal control character. Great! Except it seems to work on all the control characters I've tried except <C-i> (which prints a regular tab, rather than ^I with the special/bolded syntax highlighting I see for other literal control characters). What gives?

(I thought maybe it was because various plugins map <C-i> to lots of things, so I moved my "bundle" folder elsewhere, reloaded vim, and tried again! Still no luck.)

If it helps/matters, I'm running gVim 7.4 on Windows. I also found this, but <C-q><C-i> doesn't do it, either.

2

You can do it like this:

let &breakat = "-/ \t"

set syntax is weird, you probably want to avoid it if possible. Fortunately set option=... is equivalent to let &option = ..., and let syntax is nicer. In particular let allows you to use full expressions as values, such as the above.

On a related topic, setlocal option=... is equivalent to let &l:option = ....

  • Brilliant; that totally did it! Do you do this for all settings in your .vimrc? – Ryan Lue Jun 26 '15 at 6:12
  • @RyanLue This trick is mostly useful for string-valued options, or when saving / restoring options in scripts. I don't bother with it otherwise. – lcd047 Jun 26 '15 at 6:19
1

I'm running gVim 7.4 on Windows.

From :help i_CTRL-V:

Note: When CTRL-V is mapped (e.g., to paste text) you can often use CTRL-Q instead i_CTRL-Q.

mswin.vim maps <C-v> to paste text.

That being said, using \t as suggested by lcd047 is probably better here, since it's more readable and easier to edit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.