Improving Vim auto complete for CSS class names
Just a quick tip about Vim autocompletion.
I’ve been using the excellent SuperTab Vim Plugin for a couple years, it works reasonably well (autocompletes based on words from all buffers, file names, tags, context, etc…) but it doesn’t work really well for text that is split by dashes - CSS contains lots of these… - so I started to get frustrated with it.
You can change the auto complete behavior with set iskeyword
which also changes the behavior of standard motion commands like w
, e
, b
(it changes the word delimiters) – which a find a PITA since I got used to these motions. My quick and dirty solution to the problem was to keep iskeyword
with the minimal value as possible and only change it during InsertEnter
. That way I can still use cw
, ve
, db
to edit each fragment, autocomplete will work properly for words like foo-bar__baz
, and you can still use W
, B
and E
if you want to quickly jump around. For me that’s the best of both worlds!