-2

How do I delete text probably multiple lines in vi(m)?

Tried the backspace button to delete. Works not!

Deleted lines of text.enter image description here

EdChum
  • 376,765
  • 198
  • 813
  • 562
Zodiac
  • 13
  • 4
  • Hello and welcome to StackOverflow! :) Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve). – char Apr 01 '19 at 08:02
  • Required reading: [Your problem with Vim is that you don't grok vi.](https://stackoverflow.com/a/1220118/240443) – Amadan Apr 01 '19 at 08:21
  • Also: [vi.se] exists – D. Ben Knoble Apr 01 '19 at 23:42

2 Answers2

2

By default, in Vi/Vim, backspace does not work as we are used to] (cf :help bs, in Vim).

If you are in Vim, you can set it to behave the way you want with:

:set bs=indent,eol,start

If you are in Vi only, I refer you to @user31264's answer.

padawin
  • 4,230
  • 15
  • 19
1

Some most common delete commands:

Delete 123 lines from the current one: d123d or 123dd

Delete one line: dd

Delete 1 character: x

Delete 123 characters: 123x

Delete till the end of the current word (word is a sequence of alphanumeric characters, or one non-alphanumeric non-space character): dw or de

As above, word is a sequence of any characters except whitespace: dW or dE

As above, delete 123 words: 123dw, 123de, 123dW, or 123dE

user31264
  • 6,557
  • 3
  • 26
  • 40