tmux-complete.vim icon indicating copy to clipboard operation
tmux-complete.vim copied to clipboard

sh: fix "remove surrounding non-word characters"

Open blueyed opened this issue 10 years ago • 5 comments

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

blueyed avatar Mar 11 '15 21:03 blueyed

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

  • foo
  • bar
  • foo-bar

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.

wellle avatar Mar 12 '15 09:03 wellle

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").

blueyed avatar Mar 12 '15 11:03 blueyed

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?

wellle avatar Mar 12 '15 11:03 wellle

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.

blueyed avatar Mar 12 '15 11:03 blueyed

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.

wellle avatar Mar 12 '15 11:03 wellle