bkad / CamelCaseMotion

A vim script to provide CamelCase motion through words (fork of inkarkat's camelcasemotion script)
589 stars 45 forks source link

Changing words deletes a trailing underscore #10

Open oconnor663 opened 12 years ago

oconnor663 commented 12 years ago

Normal vim behavior:

CamelCaseMotion behavior:

Awesome plugin, by the way, thanks a million!

bkad commented 12 years ago

Good point, I'll take a look when I get some time.

All thanks should be directed to @inkarkat for authorship of the plugin.

inkarkat commented 12 years ago

The c,w mapping includes the whitespace after the word, but built-in cw does not. This is a Vim special case that custom motions cannot replicate. Cp. :help cw

If you want the trailing underscore to remain, use c,e.

@bkad: Thanks for including me on the discussion. I guess I'll watch your repo now to be informed of the issues that arrive here. Seems like many people don't fully realize that yours is just a fork, or find it easier to complain here.

dlee commented 12 years ago

@inkarkat It's because we couldn't find your github. I looked through your projects and couldn't find camelcasemotion. Is there a place to file issues against your repo?

dlee commented 12 years ago

@inkarkat @oconnor663 What about mapping c,w to whatever implements c,e? Would that cause unexpected behavior in certain scenarios?

inkarkat commented 12 years ago

@bkad: You may be too young to know this, but there was software development before GitHub :-) Just send issues and patches to me via email (the address is listed in the script's header and help file).

I do know the benefits of GitHub; I just haven't moved my own Vim plugins there.

dlee commented 12 years ago

@inkarkat You may be too old to realize this, but issue tracking happens on an issue tracker for open source projects nowadays :-)

On a serious note, you have a github account, but the camelcasemotion project isn't listed, so it's easily assumed that you're not maintaining it anymore. The last update before you found this github repo was in 2009.

You should really consider moving your vim plugins to github.

oconnor663 commented 12 years ago

This is interesting. Here's some more discussion of the builtin vim behavior: https://groups.google.com/forum/?fromgroups=#!topic/vim_use/iLZJm7ywh40

I notice that ciw has similar special casing to cw, and that ci,w lacks that special casing just like c,w. However, ci,e seems to do the Right Whitespace Thing just like c,e did, even though cie isn't actually a command that exists.

I'm unfamiliar with vimscript, so maybe this is a stupid question, but is there any good way to simply map c,w and ci,w to the e variants by default in the plugin? Or would that make questionable assumptions about the user's keybindings?

inkarkat commented 12 years ago

Try

:nmap c,w c,e
:nmap ciw cie

If you don't run into problems with that (I don't see why you should), I could add this to the plugin, either as a configurable default (when you use the default mappings) or a note in the documentation to apply the special case. What are your thoughts? I have never relied on this special case, so I don't know whether the majority of users would expect this or rather find this strange.

henrik commented 11 years ago

I think @inkarkat means

:nmap ci,w ci,e

for the second line.

Also: cool. I've been annoyed by this but not quite aware of why. Will try those mappings.

henrik commented 11 years ago

This won't fix things like c2,w of course, but I'll take what I can get.

henrik commented 11 years ago

I've used the suggested mappings since my last comment; haven't had any problems.

trq commented 10 years ago

I seem to be having some similar issue. Placing the cursor on the 's' in 'sent' in the following:

return $this->sentAt;

and typing ciw, I end up in insert mode with a space (and my cursor) just before A:

return $this-> At;
Asheq commented 8 years ago

To be comprehensive, you can also add this line to your vimrc: :nmap di,w di,e

This is in addition to the aforementioned:

:nmap c,w c,e :nmap ci,w ci,e

gerazov commented 2 years ago

Very useful - should be a default feature!