On Tue, Oct 17, 2006 at 05:43:08AM -0500, Tim Chase wrote:
> In some text, I've got compound words separated by a single 
> hyphen.  For convenience of yanking, I've added the hyphen to my 
> iskeyword setting which works nicely for the most part.  However, 
> I also use a doubled-hyphen to the effect one would use an 
> em-dash which leads to the unwanted situation that a yank of a 
> "word" now includes the first word of the subordinate sentence 
> structure--such as this where the dashes are doubled--and effects 
> my ^N/^P searching (as duplicates appear for entries followed by 
> the double-dash).
> 
> I'm on the prowl for some way to keep the iskeyword behavior for 
> things like "doubled-hyphen" and "em-dash" in the above 
> paragraph, but exclude things like "structure--such" and 
> "doubled--and", limiting the "word" to things with a dash only if 
> that dash is not repeated.  Something like "\w-\w" but not 
> "\w-\+\w" (assuming that "-" isn't part of iskeyword for this 
> example)
> 
> Any hints?

     Let's think big and look for a generic solution.  IMHO, it is way
too restrictive to insist that a word is anything matching the pattern
/\k\+/ .  I want a new option, 'wordpat', with a default value of
'\k\+', that specifies what should be recognized as a word, for purposes
of search patterns, Normal-mode commands such as w and b, and maybe
other uses.  (Oh, yes:  Insert-mode completion.)

Examples:

:let &l:wordpat = '\k\+\(-\k\+\)*'

allows words-with-hyphens but--as requested--does not match double
hyphens.  Change the '*' to '\=' to allow no more than one hyphen per
word.  C programmers may like to use '\.' instead of '-'.

:let &l:wordpat = '\\\=\k\+'

matches TeX commands like \def and \input and caters to the (lazy but
common) style of omitting optional white space:
        $ \alpha\beta\gamma=\alpha+\beta+\gamma $.

:let &l:wordpat = '\a\l*'

matches Capitalized words but rejects CamelCase words.

     What do you think?  Would this solve enough problems to be worth
the effort?  How many vim users would add it to their wish lists?

HTH                                     --Benji Fisher

Reply via email to