Vim Tips Wiki
m (Contributor added to the author field)
(Undo revision 19979 by 82.74.73.168 (talk))
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
  +
{{TipImported
{{Tip
 
 
|id=1469
 
|id=1469
  +
|previous=1468
|title=Ctrl-N completion for XML/XSLT attributes
 
  +
|next=1470
|created=January 12, 2007 10:55
+
|created=January 12, 2007
 
|complexity=basic
 
|complexity=basic
|author=Erik Falor and pagaltzis--AT--gmx.de
+
|author=Erik Falor
 
|version=n/a
 
|version=n/a
 
|rating=7/7
 
|rating=7/7
  +
|category1=Completion
|text=
 
  +
|category2=XML
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 .
 
 
}}
 
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:
  +
<pre>
 
if has("autocmd")
 
autocmd FileType {xml,xslt} setlocal iskeyword=@,-,\:,48-57,_,128-167,224-235
 
endif "has("autocmd")
  +
</pre>
   
 
'''Notes'''
Add this to your .vimrc so that hyphens and colons:
 
 
*This does not rely on extensions; instead it works on any file which the filetype detection identifies correctly.
if has("autocmd")
 
 
*It only changes the 'iskeyword' value for that buffer, not globally.
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.
 
}}
 
   
 
==References==
 
==References==
 
*{{help|:autocommand}}
 
*{{help|:autocommand}}
 
*{{help|'isk'}}
 
*{{help|'isk'}}
  +
*{{help|file-pattern}}
  +
 
==Comments==
  +
Shouldn't those ''word character'' settings rather be put into the appropriate filetype plugin?
   
== Comments ==
 
 
----
 
----
<!-- parsed by vimtips.py in 0.232741 seconds-->
 
[[Category:XML]]
 
[[Category:Automated_Text_Insertion]]
 

Latest revision as of 06:14, 28 September 2008

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.

References[]

Comments[]

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