How does this series of keystrokes in vim remove everything except numbered lines?

We work through only the average kata,

Leave only the
numbered lines.
LINE 1
LINE 2
LINE 3
That all.
Thank you
very much.

The following keystroke sequence makes sense and does something in the buffer:

djGd2kZZ

It mainly brings together teams. But what exactly is being done, and why don't I see it in the buffer? I tried to omit "q!" (quit?), but then it didn’t work.

)3:wq!<CR>
+4
source share
1 answer

)is motion that leaps forward by one sentence. Sentence:

*sentence*

    A sentence is defined as ending at a '.', '!' or '?' followed by either the
    end of a line, or by a space or tab.

In this file:

Leave only the
numbered lines.
LINE1

The first two lines are a sentence ending with a period and a new line, so it )moves the cursor to the beginning LINE 1.

:wq!<CR> - , .

, :w

:[range]w[rite][!] [++opt]

    Write the specified lines to the current file.  This
    is unusual, because the file will not contain all
    lines in the buffer.

: N: Count Range

Count and Range                     *N:*

    When giving a count before entering ":", this is translated into:
        :.,.+(count - 1)

    In words: The 'count' lines at and after the cursor.  Example: To delete
    three lines:
        3:d<CR>    is translated into: .,.+2d<CR>

3:w :.,.+2w, .

)3:wq!<CR> , , . , Vim . - .

( djGd2kZZ , , []: w, ).

+5

All Articles