Specifying a count to the yy, dd, cc, >>, << and !! commands

10 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Jun 12, 2021, 10:28:17 AM6/12/21
to vim_dev
Hi all,

A count can be specified before or after the first letter of the
yy, dd, cc, >>, << and !! commands. This is not mentioned in
the Vim help. There are a couple of discussions regarding this:

https://vi.stackexchange.com/questions/31428/removing-multiple-lines-d3d-vs-3dd
https://vi.stackexchange.com/questions/2543/how-can-i-map-dcountd

The opengroup Vi specification indirectly mentions this:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html#tag_20_152_13_02

It would be good to mention this in the Vim help.

Regards,
Yegappan

Bram Moolenaar

unread,
Jun 13, 2021, 9:25:36 AM6/13/21
to vim...@googlegroups.com, Yegappan Lakshmanan
We can add something below ":help operator". It already mentions that a
count on the operator and a count on the motion is multiplied. How
about this:

*motion-count-multiplied*
If the motion includes a count and the operator also had a count before it,
the two counts are multiplied. For example: "2d3w" deletes six words.
*operator-doubled*
When doubling the operator it operates on a line. When using a count, before
or after the first character, that many lines are operated upon. Thus `3dd`
deletes three lines. A count before and after the first character is
multiplied, thus `2y3y` yanks six lines.

--
Hacker: Someone skilled in computer programming (good guy).
Cracker: A hacker that uses his skills to crack software (bad guy).

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yegappan Lakshmanan

unread,
Jun 13, 2021, 9:29:13 AM6/13/21
to Bram Moolenaar, vim_dev
Hi Bram,

On Sun, Jun 13, 2021 at 6:25 AM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
>
> Yegappan wrote:
>
> > A count can be specified before or after the first letter of the
> > yy, dd, cc, >>, << and !! commands. This is not mentioned in
> > the Vim help. There are a couple of discussions regarding this:
> >
> > https://vi.stackexchange.com/questions/31428/removing-multiple-lines-d3d-vs-3dd
> > https://vi.stackexchange.com/questions/2543/how-can-i-map-dcountd
> >
> > The opengroup Vi specification indirectly mentions this:
> > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html#tag_20_152_13_02
> >
> > It would be good to mention this in the Vim help.
>
> We can add something below ":help operator". It already mentions that a
> count on the operator and a count on the motion is multiplied. How
> about this:
>
> *motion-count-multiplied*
> If the motion includes a count and the operator also had a count before it,
> the two counts are multiplied. For example: "2d3w" deletes six words.
> *operator-doubled*
> When doubling the operator it operates on a line. When using a count, before
> or after the first character, that many lines are operated upon. Thus `3dd`
> deletes three lines. A count before and after the first character is
> multiplied, thus `2y3y` yanks six lines.
>

Looks good to me.

Regards,
Yegappan
Reply all
Reply to author
Forward
0 new messages