vim-better-whitespace
vim-better-whitespace copied to clipboard
Prepopulate blacklist variable
I wanted to leave the original blacklist untouched and simply append a type (btw, even though it is a custom one from taskwarrior, you could add that in natively, because you should never highlight or strip white-space in that file - it is prepopulated with lots of trailing white-spaces and will be trimmed automatically on save):
let g:better_whitespace_filetypes_blacklist += ['taskedit']
But I got the error that the variable was undefined - how about predefining that variable so that we can extend it? My concern here is that if you update the blacklist, I would have to manually update mine. Also DRY.
The variable is predefined, but plugins aren't yet loaded while your vimrc is being read. Setting an auto command to append to the list after startup should work:
autocmd VimEnter * let g:better_whitespace_filetypes_blacklist += ['taskedit']
Ah, that makes sense, thanks! But unfortunately, this doesn't seem to work :/
Hm, looks like that's due to the plugin setting everything up on FileType
, WinEnter
, and BufWinEnter
events, all of which fire before VimEnter
... 😕
I suppose a workaround would be to just disable it for that file type (with a check to prevent any errors if you ever don't load the plugin):
autocmd FileType taskedit if exists(":DisableWhitespace") | execute ":DisableWhitespace" | endif
@Cimbali, any ideas on a better way to handle this?
Yes, this works for now, thank you :)
I’m afraid I don’t have a better solution right now. I can see 2 only options:
- copy the blacklist, or
- add an “append to blacklist“ option
Actually the VimEnter
technique works for me in Vim 8.1