> For the complete documentation index, see [llms.txt](https://ricardomol.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ricardomol.gitbook.io/notes/assorted/vim.md).

# Vim

## **Delete lines**

### Delete single line

&#x20;**`dd`**

### Delete all lines

**`:1,$d`** o&#x72;**`:%d`**

### Delete multiple lines

Prefix the dd command with the number of lines you want to delete below it.&#x20;

If you want to delete 3 consecutive lines below:**`# 3dd`**

### Delete lines by a given pattern <a href="#id-5" id="id-5"></a>

#### Delete lines that contain a certain word, press ESC and run

`:g /word/d`

#### Delete every line that doesn't contain the word "lazy"

`:%g!/lazy/d` or `:v/lazy/d`

#### Delete lines that begin with a certain letter, say 'A'

`:g/^A/d`

#### Delete lines that begin with a special character like $ sign, prefix the character with a backslash

`:g/^\$/d`

#### Get rid of all blank lines

`:g/^$/d`
