# Vim Mode

Vim is an editor to create or edit a text file.&#x20;

{% embed url="<https://docs.google.com/presentation/d/15GyPedfwTgNicd2esmipPzCoLwYmFVIRAElPXRLnvss/edit?usp=sharing>" %}

![Source: http://www.viemu.com/a\_vi\_vim\_graphical\_cheat\_sheet\_tutorial.html](/files/-LqnK441fKXw2ZWfSfLo)

## Command Mode

In the command mode, user can move around the file, delete text, etc.

| Key      | Explanation                                  |
| -------- | -------------------------------------------- |
| h        | Moves the cursor one character to the left   |
| l        | Moves the cursor one character to the right  |
| k        | Moves the cursor up one line                 |
| j        | Moves the cursor down one line               |
| nG or :n | Cursor goes to the specified (n) line        |
| ^F       | (CTRl F) Forward screenful                   |
| ^B       | Backward screenful                           |
| ^f       | One page forward                             |
| ^b       | One page backward                            |
| ^U       | Up half screenful                            |
| ^D       | Down half screenful                          |
| $        | Move cursor to the end of current line       |
| 0        | Move cursor to the beginning of current line |
| w        | Forward one word                             |
| b        | Backward one word                            |
|          |                                              |

### Exit Commands

|     |                                                                   |
| --- | ----------------------------------------------------------------- |
| :wq | Write file to disk and quit the editor                            |
| :q! | Quit (no warning)                                                 |
| :q  | Quit (a warning is printed if a modified file has not been saved) |
| ZZ  | Save workspace and quit the editor (same as :wq)                  |

### File Manipulation Commands

|         |                                          |
| ------- | ---------------------------------------- |
| :w      | Write workspace to original file         |
| :w file | Write workspace to named file            |
| :e file | Start editing a new file                 |
| :r file | Read contents of a file to the workspace |

### Text Deletion Commands

|    |                             |
| -- | --------------------------- |
| x  | Delete character            |
| dw | Delete word from cursor on  |
| db | Delete word backward        |
| dd | Delete line                 |
| d$ | Delete to end of line       |
| d^ | Delete to beginning of line |

### Yank Commands

|    |                                         |
| -- | --------------------------------------- |
| yy | yank current line                       |
| y$ | yank to end of current line from cursor |
| yw | yank from cursor to end of current word |

### Paste

|   |                    |
| - | ------------------ |
| p | paste below cursor |
| P | paste above cursor |
|   |                    |

### Undo

|   |                  |
| - | ---------------- |
| u | Undo last change |
| U | Restore line     |

### Change from command mode to insert mode

**From** command mode **to** insert mode type **a**/**A**/**i**/**I**/**o**/**O** ( see details below)

## Insert Mode

In the insert mode, user can insert text.

**Changing mode from one to another**

### Change from insert mode to command mode

**From** insert mode **to** command mode type **Esc** (escape key)

Some useful commands for VIM

| Key | Explanation                                                        |
| --- | ------------------------------------------------------------------ |
| a   | Append text following current cursor position                      |
| A   | Append text to the end of current line                             |
| i   | Insert text before the current cursor position                     |
| I   | Insert text at the beginning of the cursor line                    |
| o   | Open up a new line following the current line and add text there   |
| O   | Open up a new line in front of the current line and add text there |

&#x20;

**To create a page break,** while in the insert mode, press the CTRL key

And l. ^L will appear in your text and will cause the printer to start

A new page.

**Other Useful Commands**

Most commands can be repeated n times by typing a number, n, before

the command. For example 10dd means delete 10 lines.

. Repeat last command

cw Change current word to a new word

r Replace one character at the cursor position

R Begin overstrike or replace mode � use ESC key to exit

:/ pattern Search forward for the pattern

:? pattern Search backward for the pattern

n (used after either of the 2 search commands above to

continue to find next occurrence of the pattern.

:g/pat1/s//pat2/g replace every occurrence of pattern1 (pat1) with


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pythonclassroom.com/python-cloud-options/cloud9/vim-mode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
