Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Mar 11, 2015

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

'\w.*\.*' matches 'foo-bar', although only 'foo' and 'bar' should get
matched there.
@wellle
Copy link
Owner

wellle commented Mar 12, 2015

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.

@blueyed
Copy link
Contributor Author

blueyed commented Mar 12, 2015

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
Copy link
Owner

wellle commented Mar 12, 2015

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
Copy link
Contributor Author

blueyed commented Mar 12, 2015

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
Copy link
Owner

wellle commented Mar 12, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants