vim

Toggle vim setting with vimscript function


I'm trying to write a function that toggles the set list attribute, in order to map the function later to a command.

I have the following written:

function! ShowMarksToggle()
  if (&list == 0)
    set list
  else
    set nolist
  endif
endfunction

The function gets parsed and runs (with :call ShowMarksToggle()) without any warning, however the settings doesn't gets toggled.

What am I missing?


Solution

  • You should use :set list!, instead.