sponsor Vim development Vim logo Vim Book Ad

basic Tip #1469: Ctrl-N completion for XML/XSLT attributes

 tip karma   Rating 7/7, Viewed by 1903 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   January 12, 2007 10:55      complexity:   basic
author:   Erik Falor      as of Vim:  

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 hypen 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 so that hyphens and colons:

if has("autocmd")
    autocmd BufRead *.xsl,*.xslt,*.xml :set iskeyword=@,-,\:,48-57,_,128-167,224-235
endif "has("autocmd")

 rate this tip  Life Changing Helpful Unfulfilling 

<< Backward search for latex documents on Mac os x | Status line to display more information >>

Additional Notes

[email protected], January 13, 2007 0:52
Here’s a better way to do that:

autocmd FileType {xml,xslt} setlocal iskeyword=@,-,\:,48-57,_,128-167,224-235

Firstly, this does not rely on extensions; instead it works on any file which the filetype detection identifies correctly.

Secondly, it only changes the 'iskeyword' value for that buffer, not globally.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo