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?

Thanks,

-tim




After reading this thread, I've seen "requests for improvement" to the Vim source; but let's try to find (for the time being) something which works in the current Vim version.

1. Em dashes should normally be set apart from the neighbouring words by blank spaces -- like this -- and if they are, they won't be mistaken for part of a word regardless of whether 'iskeyword' includes the dash.

2. To toggle the "kewordness" of the dash character on the fly:

        :map    <F5>    :set isk+=-<CR>
        :map    <S-F5>  :set isk-=-<CR>
        :imap   <F5>    <C-O>:set isk+=-<CR>
        :imap   <S-F5>  <C-O>:set isk-=-<CR>

3. To add spaces between em dashes and the adjoining words (but not between an em dash and a space, comma, full stop, line break, etc.):

        :%s/\(\k\)--/\1 --/g
        :%s/--\(\k\)/-- \1/g


Best regards,
Tony.

Reply via email to