I have used this script to be able to highlight results from test reports: https://vim.fandom.com/wiki/Highlight_multiple_words
When using it in Vim, it works fine when I type :Highlight 1 FAILED
(For some reason the numpad-keys don't work).
Unfortunately, this is not session persistent, so I tried to add it to my .vimrc:
" auto highlight PASSED, FAILED, ERROR, SKIPPED
:Highlight 1 FAILED
:Highlight 4 ERROR
:Highlight 2 SKIPPED
:Highlight 3 PASSED
I would have expected this to work, but it doesn't. I get these errors when starting Vim:
Error detected while processing /home/wouter/.vimrc:
line 174:
E492: Not an editor command: :Highlight 1 FAILED
line 175:
E492: Not an editor command: :Highlight 4 ERROR
line 176:
E492: Not an editor command: :Highlight 2 SKIPPED
line 177:
E492: Not an editor command: :Highlight 3 PASSED
Press ENTER or type command to continue
What am I doing wrong here?
:Highlight
command is not yet sourced by the time the vimrc file is loaded. Simple way to fix it: put those:Highlight
commands into a function and let that be run on anVimEnter
autocommand.:help startup
page to get an idea of when code is executed. Then take a look at:help function
and:help autocmd
for those.