tommcdo/vim-exchange

Odd behavior with cxiw

Opened this issue · 10 comments

Hi, I recently cloned your exchange plugin, but I am seeing some odd behavior.

I have the sentence:

Pass the salt and pepper.

I do cxiw on the word "salt" and then go to "pepper" and repeat cxiw (or . ) and I get:

Pass the peppert and saltr.

It does it with every word exchange and always has funny ending. I checked my mappings and their doesn't seem to be any conflicts. Any idea?

Alain

On the
capture1
capture2

This was happening because you must have :set selection=exclusive somewhere. This fix temporarily switches it to inclusive during the exchange.

Let me know if this fixes it for you :)

Yes, works perfect now. Great, I see myself using this plugin a lot.
Alain.

Glad to hear it!

Out of curiosity, do you knowingly use :set selection=exclusive for a particular reason? I've never really known anyone to do that; can't think of a reason to.

Hi Tom,
I did not know about set selection = exclusive until you told me about it.
I made sure there was nothing like that in my _vimrc file and I also made
sure there weren't any ftdetect settings running for other filetypes or
plugins. Ie, I worked from a simple .txt file when I tried it on the "Pass
the salt..." sentence which I showed you.
Alain

On Sat, Apr 26, 2014 at 9:16 AM, Tom McDonald notifications@github.comwrote:

Out of curiosity, do you knowingly use :set selection=exclusive for a
particular reason? I've never really known anyone to do that; can't think
of a reason to.

Reply to this email directly or view it on GitHubhttps://github.com//issues/23#issuecomment-41469817
.

Doctoral candidate, Dept. Sociology, University of Minnesota.
M.S. Statistics, University of Minnesota.

I think it's usually a pretty harmless setting; built-in operators ignore it, from what I understand, and custom operators should take it into consideration (it was an oversight that exchange didn't do this).

If you want to figure out where it's being set, you can try this:

:verbose set selection?

It tells you the last script that modified the value.

Ahh, great tip, I ran the verbose line and it appears to be from T.Pope's
surround plugin (another plugin I use often).

https://github.com/tpope/vim-surround

I hope that this finally gets to the bottom of it all. I often am reluctant
to bother plugin developers with issues since I always presume I am doing
something short sighted. But I think this issue may have made things more
helpful in the long run.

Alain.

On Sat, Apr 26, 2014 at 11:21 AM, Tom McDonald notifications@github.comwrote:

I think it's usually a pretty harmless setting; built-in operators ignore
it, from what I understand, and custom operators should take it into
consideration (it was an oversight that exchange didn't do this).

If you want to figure out where it's being set, you can try this:

:verbose set selection?

It tells you the last script that modified the value.

Reply to this email directly or view it on GitHubhttps://github.com//issues/23#issuecomment-41473021
.

Doctoral candidate, Dept. Sociology, University of Minnesota.
M.S. Statistics, University of Minnesota.

Hmm, that could be a false-positive. It seems likely that any operator would be temporarily changing that setting (as mine is now doing).

Hi Tom, when I open my GVIM from the desktop I run verbose set and see that
set selection=exclusive is initiated by

source $VIMRUNTIME/mswin.vim

which is in my _vimrc and was written by B. Moolenaar to mimic popular
commands like etc.

With your latest commit, the cxiw keys work with "Please pass the salt and
pepper." Interestingly, when I run the
verbose set again it shows selection=exclusive and says the file to last
set it was exchange.vim. (But that may be
because your new commit sets inclusive behind the scenes and returns it to
exclusive--I don't know).

Also, following Drew Neil's vimcast, I do ve on "salt" which visually
selects the word but then cx deletes it and types
out an "x". (But maybe the mappings have changed since then, I say this
because that may be another clue if
exchange.vim is supposed to work as D. Neil demonstrated it.)

Alain.

On Sat, Apr 26, 2014 at 12:39 PM, Tom McDonald notifications@github.comwrote:

Hmm, that could be a false-positive. It seems likely that any operator
would be temporarily changing that setting (as mine is now doing).

Reply to this email directly or view it on GitHubhttps://github.com//issues/23#issuecomment-41475237
.

Doctoral candidate, Dept. Sociology, University of Minnesota.
M.S. Statistics, University of Minnesota.

Yes, the Visual mapping has changed to X, because the original cx mapping shadowed the built-in c operator (this is only an issue in Visual mode).

I think it's mentioned in the show notes of the Vimcast episode, but the video itself was never updated.