wellle / tmux-complete.vim

Vim plugin for insert mode completion of words in adjacent tmux panes
MIT License
515 stars 21 forks source link

sh: fix "remove surrounding non-word characters" #57

Open blueyed opened 9 years ago

blueyed commented 9 years ago

'\w.*\w' matches 'foo-bar', although only 'foo' and 'bar' should get matched there.

wellle commented 9 years ago

I disagree. I think all of these should match (which currently do):

This is especially useful when completing filenames, paths or URLs. Even the screenshot in the Readme shows that behavior: https://github.com/wellle/tmux-complete.vim#but-fear-no-longer

But we could add some plugin options to choose between words and WORDs. In the script it could be a new split mode WORDS.

blueyed commented 9 years ago

Ok, there's the difference between word and WORD then, but we agree that 'foo bar' should not get matched, right? :)

The problem with the current pattern is that it matches anything between two word characters, including spaces etc.

I'd say to extend the \w then by e.g. using grep -o "[_[:alnum:]-]*" (for "word").

wellle commented 9 years ago

The problem with the current pattern is that it matches anything between two word characters, including spaces etc.

No it doesn't. It was split on spaces before surrounding non word characters are stripped. Can you show me an example of what gets matched but shouldn't?

blueyed commented 9 years ago

It was split on spaces before surrounding non word characters are stripped.

Oh, I forgot about that part. Sorry.

Then it's just about WORD vs. word, yes.

wellle commented 9 years ago

So yeah, if you only want WORDs instead of words, we should add a new split mode WORDS (new default by plugin) rename splitwords to splitWORDS and add a new function splitwords that splits on any non word chararters (no stripping needed then).

If you want to use that for completion, then a new plugin setting for splitmode would be needed. That way we could even allow linewise completions. #26

Thinking about it, another useful completion mode could be half lines, beginning at some pattern but extending to the end of line, similarly to C-XC-L. But that would be another issue.