How do I unset a specific vim command?

34

6

set listchars=tab:>-,trail:_

I tried to unset the above command this way:

unset listchars=tab:>-,trail:_

But only get:

E492: Not an editor command: unset listchars=tab:>-,trail:_

What's the right way to do this?

gbri

Posted 2011-07-18T15:56:34.010

Reputation: 423

Answers

41

This will reset the listchars option to the default:

set listchars&

See the options documentation for more info.

Chris Acheson

Posted 2011-07-18T15:56:34.010

Reputation: 1 089

Handy to know, thanks. Also works for :set rightleft – aportr – 2014-09-12T01:59:46.920

will unset listchars= work? – gbri – 2011-07-18T16:20:06.640

5There's no unset command. For toggleable options, you can do set nooption (example: set paste and set nopaste), but listchars is not toggleable. If you actually want to set listchars to have no value, do: set listchars= – Chris Acheson – 2011-07-18T16:35:57.957

so set listchars& is the same as set listchars=? – gbri – 2011-07-19T11:04:43.127

1set listchars& sets it to the default setting that it started with, which is eol:$ – Chris Acheson – 2011-07-19T15:27:36.463

11

There are 3 primary ways to unset a variable. I will use the binary command here for demonstration purposes. One of them should work.

  1. set nobinary
  2. set binary&
  3. set binary!

Remember to reload the file you are working on for the values to apply again using :e

alpha_989

Posted 2011-07-18T15:56:34.010

Reputation: 623