6

I don't do tabs, so usually my

listchars=tab:▸ ,nbsp:␠,trail:·,precedes:«,extends:»

But it gets annoying with some sources. I'd like to subtract tab: from lcs in some filetypes. I've tried setlocal lcs-=tab (also tab:.*) to no avail.

Short of programatically re-computing lcs, what to do?

Edit: clearing tab: results in ^I's, so maybe I actually want to replace the sub-key, not remove it; nevertheless I'm still curious about the original question

11
  • 2
    If there's no easy answer (I'm not aware of one) you can use a one-liner for that programattic approach, e.g. something like let &listchars = join(filter(split(&listchars, ","), 'v:val !~ "tab:"'), ",")
    – B Layer
    Jul 16, 2021 at 11:58
  • 2
    In such cases (where I ran it interactively), I usually do :set lcs=<C-R>=&lcs<cr>. Now you have the current value in the commandline and I just use the cursor keys to remove what I do not want Jul 16, 2021 at 12:05
  • Yeah, I might have noted that my one-liner would be good for, say, a script but not so much in the interactive / manually typed case!
    – B Layer
    Jul 16, 2021 at 12:06
  • 1
    @ChristianBrabandt I use setl lcs=<tab> which lets me edit the current value, but, like I said, it gets annoying
    – usretc
    Jul 16, 2021 at 12:07
  • 1
    Are you asking me? I can assure you, I know a bit how Vim works. Really. Jul 16, 2021 at 13:32

1 Answer 1

5

The answer is at :help :set-=:

:se[t] {option}-={value}                *:set-=*
            Subtract the {value} from a number option, or remove
            the {value} from a string option, if it is there.
            If the {value} is not found in a string option, there
            is no error or warning.  When the option is a comma
            separated list, a comma is deleted, unless the option
            becomes empty.
            When the option is a list of flags, {value} must be
            exactly as they appear in the option.  Remove flags
            one by one to avoid problems.
            Also see |:set-args| above.

That is, you must use :set listchars-=tab:▸\ (I'm pretty sure the space needs escaped here).

1
  • Ah. So, too brittle to be useful in this case.
    – usretc
    Jul 16, 2021 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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