Wikia

Vim Tips Wiki

Ctrl-N completion for XML/XSLT attributes

Talk0
1,613pages on
this wiki
Tip 1469 Printable Monobook Previous Next

created January 12, 2007 · complexity basic · author Erik Falor · version n/a


I found myself switching back into lisp mode just to get Ctrl-N to complete really long attribute names containing hyphens. However, that has the undesirable side-effect of goofing up my indentation. I decided to dig in a little deeper and fix Ctrl-N such that it wouldn't take a hyphen to be a word boundary. As an added bonus, it'll include XSL namespace prefixes in its list of words.

Add this to your vimrc:

if has("autocmd")
  autocmd FileType {xml,xslt} setlocal iskeyword=@,-,\:,48-57,_,128-167,224-235
endif "has("autocmd")

Notes

  • This does not rely on extensions; instead it works on any file which the filetype detection identifies correctly.
  • It only changes the 'iskeyword' value for that buffer, not globally.

ReferencesEdit

CommentsEdit

Shouldn't those word character settings rather be put into the appropriate filetype plugin?


Around Wikia's network

Random Wiki