Vi command

Hi guys, does anybody know what the following command means when it is typed after ":" in vi editor:

:182,361d181

I know what 182,361d does (deletion lines 182 till 361) but not sure what the last 181 means.

Any advice.
Thanks a lot

181 -> positions the cursor after line 181.

1 Like
:182,361d181

It will delete 181 lines from 361th line and place the cursor at 361th line

1 Like

Note that while the line range says delete (361 - 182 + 1)=180 lines, the count suffix says delete 181 lines and wins, so it is equivalent to ":181,362d", and the file now contains 1-360 and 542-$, with the cursor sitting at pos 1 (not after) of former line 542, new line 361.

Delete
Synopsis:
[2addr] d[elete][buffer][count][flags]
Delete the specified lines into a buffer (defaulting to the unnamed buffer), which shall become a line-mode buffer.

Flags can immediately follow the command name; see Command Line Parsing in ex .

Current line: Set to the line following the deleted lines, or to the last line in the edit buffer if that line is past the end of the edit buffer, or to zero if the edit buffer is empty.

Current column: Set to non- <blank>.

count A positive decimal number. If count is specified, it shall be equivalent to specifying an additional address to the command, unless otherwise specified by the following command descriptions. The additional address shall be equal to the last address specified to the command (either explicitly or by default) plus count-1.

1 Like