Delete from cursor to end of line under visual selection in vim

I have a code segment as shown below.

type Account struct {                                                                                                                                                                                       
    Id                         int                                                                                                                                                                          
    UserId                     int                                                                                                                                                                          
    Name                       string                                                                                                                                                                       
    Address                    string                                                                                                                                                                       
    City                       string                                                                                                                                                                       
    State                      string                                                                                                                                                                       
    CountryId                  string 
}

I want to delete all data types. Is there a keyboard shortcut?

I tried <C-V>and selected the first letter of all data types in a vertical line, hoping d + $to work on the message, but vim only accepts the first input dand removes the first letter.

+4
source share
5 answers

Use <C-v>to enter visual block mode, select the lines that you want to change, and then Dto delete them to the end.

From :h v_D:

{Visual}["x]X   or                  *v_X* *v_D* *v_b_D*
{Visual}["x]D       Delete the highlighted lines [into register x] (for
                    {Visual} see |Visual-mode|).  In Visual block mode,
                    "D" deletes the highlighted text plus all text until
                    the end of the line.  {not in Vi}

, , , X D (X , ).

+6

, % :

s/ \+[^ ]* *$/

:

type Account struct
    Id
    UserId
    Name
    Address
    City
    State
    CountryId
}

.

+3

C-V , $ , x d .

+2
  • v6j.
  • :'<,'>norm ElD ('<,'> ).

!

0

,

  • vi{ -
  • '<,'>norm weld$ ( : normal weld $)

witch

  • '<,'>norm -
  • wel - go to the end of the first word
  • d$ - delete to the end of the line
0
source

All Articles