I frequently use "ce" to replace the current word, so I go to the the
beginning of that word and type "ce". I've noticed that when the
current word is 1-letter long, the following word gets deleted too.
For instance, if I place the cursor on the 'a' of "an objective" and
type "ce", I replace only "an". If I do the same thing with "a
server", I replace both words.
Is that really the intended behavior? Shouldn't "changing until the
end of the current word" stop at the current cursor position if that
current word is 1-letter long?
The problem with this would be that 'e' needs to be able to move from
word to word. If it stays in place when the cursor is on a 1-letter
word, the cursor would be "stuck" on that word, unable to progress to
the next with a subsequent keypress. Note, for changing a
single-letter word, you can train yourself to use the "s" command
instead, which is a synonym for "cl".
While I understand your argument about jumping through words, it seems
quite strange to me that I need to take care of whether the current
word has multiple letters or not. Of course I can get used to "s", but
it's just strange that I need to take care of that. Maybe I can remap
"ce" to use either "ce" or "s" based on the length of the current
word?
Actually, an alternate idea that has proved infinitely more useful to me:
Use text-objects. Instead of "ce" try using "ciw" which will work on
words of all lengths and is (I have found) usually what I want to do
anyway.
See :help text-objects and :help iw
In addition, text-objects can be used with the cursor _anywhere_
within the word, instead of requiring you to place the cursor at the
beginning of the word.
The problem is your misunderstanding of the meaning of 'e'. It does
not mean "go to the end of the word." It means "go forward to the
next end of a word." You have assumed a meaning from your
experience with e's behavior when your cursor is at the start of a
multi-letter word. That assumption was reasonable in that context,
but it was incorrect.
You may find it useful to use 'cw' in place of your current use of
'ce'. 'cw' should behave consistently and always change from the
cursor to the end of the current word. See
:help w
:help iw
'ciw' will change the entire current word even when the cursor is
not at the start of the word.
Regards,
Gary
Regards,
Chip Campbell
Thanks, I wasn't aware of that. That's what is nice with Vim, you
always learn something new :)
On Tue, Jun 3, 2008 at 6:43 PM, Gary Johnson <gary...@spk.agilent.com> wrote:
> You may find it useful to use 'cw' in place of your current use of
> 'ce'. 'cw' should behave consistently and always change from the
> cursor to the end of the current word. See
Once again something new :)
I actually never tried "cw" since I would have thought it would have
eaten the space as well.
Hehe. I had never realised that 'cw' behaves consistently in this fashion, but it
is very nice. I will be using it, as I had the same problem with 'e' and none of
the other solutions work for me: I usually use 'ce' or 'de' once and then '.' a
whole stack of times, so substituting 's' when I come to a single letter word is
not an option, nor are text objects as I am often changing or removing word tails
or suffixes.
Pity it's completely inconsistent with the usual motion of 'w', and with 'w' with
other operators, though. That was the assumption I made: that 'cw' would change
the same text that 'dw' deleted. Wrong!
Grins,
Ben.