wellle / tmux-complete.vim

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

use tr to split words #9

Closed ferreum closed 10 years ago

ferreum commented 10 years ago

fmt is an unclean way to split words, tr does this nicely.

wellle commented 10 years ago

:+1: Good stuff, thank you!

wellle commented 10 years ago

Hold on. It looks like this changed behavior.

ferreum commented 10 years ago

I can't see anything different here, what did you notice?

wellle commented 10 years ago
echo "a b-c" | tr -s '[:space:]' '\n' | sed -e 'p;s/[^a-zA-Z0-9_]\+/\n/g'

produces

a
a
b-c
b-c

instead of

a
a
b-c
b c
wellle commented 10 years ago

How about this?

echo "a b-c " | sed -e 'p;s/[^a-zA-Z0-9_]/ /g' | tr -s '[:space:]' '\n'

produces

a
b-c
a
b
c
wellle commented 10 years ago

I'll prepare a commit. Let me know if you see any downside of the switched order of sed and tr.

ferreum commented 10 years ago

For me, both commands produce the same lines in different order. I guess it depends on the version of sed. It's safer to tr afterwards.

wellle commented 10 years ago

Oh that's interesting. For the record I'm using BSD sed because I'm on Mac OS.

wellle commented 10 years ago

Alright, should be good now. Thanks again!