search

Home  >  Q&A  >  body text

vim - How to delete the line selected by the cursor?

Press the v key, press the shift and arrow keys, select a few lines, and then press the x key to delete.

This kind of deletion does not delete the line selected by the cursor. How to delete the line selected by the cursor in vim (not gvim)?

某草草某草草2743 days ago1552

reply all(5)I'll reply

  • 世界只因有你

    世界只因有你2017-05-16 16:35:51

    dd can delete the line where the current cursor is located. If you want to delete multiple lines, you can add the number of the line to be deleted in front of dd

    reply
    0
  • 迷茫

    迷茫2017-05-16 16:35:51

    In addition to the two people above, there is also a way to delete the content after the cursor in the line, press dt$

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 16:35:51

    Ctrl+v选中需要删除的行,dJust a moment and it’s OK!

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 16:35:51

    Shift + v is to select by row, ctrl + v is to select by block (select by column), then x and d can be deleted, similar to cutting, you can also use p to paste back.
    x alone deletes the current character, dd deletes the current line, and adding a number in front means repeating it N times.

    reply
    0
  • 为情所困

    为情所困2017-05-16 16:35:51

    In normal mode, you can use the x command to delete a single character, and the d command to delete more characters: d motion.

    motion is a command indicating the operating range. For the motions that appear in the following content, please refer to the table here:

    Button | Definition

    1. | Position the cursor at the beginning of the line

    $ | Position the cursor to the end of the line
    b | Position the cursor to the beginning of the word under the cursor
    e | Position the cursor to the end of the word under the cursor
    w | Position the cursor to the beginning of the next word
    gg | Position the cursor to the beginning of the file
    G | Position the cursor to the end of the file

    If you want to delete more characters, you can use the c command: c motion, which is similar to the d command. The difference is that after deletion, you enter insert mode.

    reply
    0
  • Cancelreply