Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between command cw and ciw in Vim?

Tags:

vim

Here's a link I find in stackoverflow about this question.

but I still cannot understand without a specific example about what's the difference between "change inner word" and "change word".

I test these two commands in my vim and finally find no differences ,Please give me an example to help me understand, thank you!

like image 740
Alec.Zhou Avatar asked Jan 20 '17 07:01

Alec.Zhou


People also ask

What does Ciw do in Vim?

To quickly change a word you can use cw , caw or ciw . Use c$ or just C to quickly change from the cursor to the end of a line, cc to change an entire line, or cis for a sentence.

What does CW mean in Vim?

The control keys. For instance, using <C-w> h (or j , k , l ) will toggle between open buffers. <C-j> will move you down a line.

What does CW command do?

The cw command preprocesses any specified troff files containing English-language text to be typeset in the constant-width (CW) font. The cw command reads standard input if you do not specify a file or if you specify a - (minus sign) as one of the input file names. The cw command writes to standard output.

What is the difference between Q and Q in Vim?

When you have some changes and use :q , it fails and throws an error stating No write since last change . In order to quit from the Vim without saving changes, you should write :q! , it will quit the Vim and ! will work as a negation, which will negate the write operation.


1 Answers

Here is an example:

foo bar baz
    ^

Typing cw and ciw will give the same result in this case (with the cursor positioned on the 'b' of 'bar'). Consider this:

foo bar baz
     ^

cw will yield

foo b baz
     ^

where ciw will yield

foo  baz
    ^

so it changes the whole word, regardless of the cursor position. Very useful, i love this command. Very useful is also the caw (or the aw) command:

foo bar baz
     ^
-> caw
foo baz
    ^

aw also contains the space. Try these commands with the v (visual) command, to see what they all do. Also, read motion.txt, part 6.

like image 135
pschulz Avatar answered Sep 23 '22 18:09

pschulz