Thursday, November 25, 2010

Re: Adding hyphen - to iskeyword ...but only for keyword completion

On Thu, Nov 25, 2010 at 5:06 AM, Tim Chase <vim@tim.thechases.com> wrote:
On 11/25/2010 02:04 AM, David Lam wrote:
I've been doing a lot of work in XQuery, where the convention is for
variable and function names to be hyphenated:

   let $this-is-some-variable := this:is-some-function()

...and to complete '$this-is-some-variable',  I'd like to type '$th<C-p>,
but by default that only completes to '$this'

On the other hand, I know I can do :set iskeyword+=- to make it complete all
the way, but it has the side effect in that it
makes the basic word motion commands move a lot further than I want them to.

anyone know any way to achieve this?

My first thought would be to do something like

 :au InsertEnter *.xquery :set isk+=-
 :au InsertLeave *.xquery :set isk-=-

It doesn't catch the edge-case if you hit ctrl+C in insert-mode (so you'd have to manually remove the "-" from 'isk' in that case; see the note at ":help InsertLeave" about ^C).

From some basic testing, it seems to do what you want:  in insert-mode, ^N/^P expansions treat "-" as part of a word, expanding whole XQuery tokens; in normal-mode, you get "word" motions interrupted by the "-" characters.

HTH,

-tim


cool! works great

i guess i can just 'imap <C-c> <ESC>' to make it still work for ^C,  hopefully that dosent have side effects for other vimscripts

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: