Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmaAlassal committed Jan 28, 2023
1 parent 2c0016e commit 4c5a1dc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
20 changes: 17 additions & 3 deletions Editors/vim/Insert-Mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ There are many ways to get into insert mode from the normal mode. Here are some
| `O ` |Starts a new line **above** the cursor and insert text. |
| `s ` |Delete the character under the cursor and insert text. |
| `S ` |Delete the current line and insert text. |
| `cw` |Delete the current word and insert text. |
| `cc` |Change line by clearing and then entering insert mode. |
| `gi` |Insert text in same position where the last insert mode was stopped.|
| `gI` |Insert text at the start of line (column 1). |

Expand Down Expand Up @@ -46,18 +48,30 @@ When you make a typing mistake, it can be cumbersome to type <Backspace> repeate
| Key | Function|
|--------|---------|
|`Ctrl-H`|Delete one character **before** the cursor.|
|`Ctrl-w`|Delete one word **before** the cursor.|
|`Ctrl-u`|Delete the entire line **before** the cursor..|
|`Ctrl-W`|Delete one word **before** the cursor.|
|`Ctrl-U`|Delete the entire line **before** the cursor..|

**Important Note**

You can't undo these deletions. However, what you've typed is still in the `.` register.


## Executing Normal Mode Command
## Executing Normal Mode Command (Insert Normal Mode)

You can use `CTRL-O` to execute a **one** normal-mode command without leaving insert mode.

When you press `Ctrl-o`, you'll be in **insert-normal** sub-mode. If you look at mode indicator on bottom left, normally you will see `-- INSERT --`, but `Ctrl-o `will change it to `-- (insert) --`.

### Example 1 : Navigating while remaining in insert mode

Let's say while typing, you wanted to add a word in the beginning of current line. Do `Ctrl-o 0` to jump to the beginning of the line, add the word, then jump back with to the end with `Ctrl-o $`.

### Example 2: Centering screen

If you're at the bottom of the screen. You can center your current position by doing `Ctrl-o zz`.

### Example 3: Deleting faster

If you wanted to delete a block of text from your current position to an anchor, say a comma, you can just do `Ctrl-o d t ,`

---------------------------------------------------------
27 changes: 25 additions & 2 deletions Editors/vim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ You should see an **intro screen**. This is the where you will be working on you

![VIM](imgs/intro-screen.png)

### Opening a File

To open a file on Vim from the terminal, run: `vim file.txt`

You can also open multiple files at once: `vim file1.txt file2.txt file3.txt`

Vim opens `file1.txt`, `file2.txt`, and `file3.txt` in separate buffers. You will learn about buffers later.

-------------------------------------------------------------

# VIM is a Modal Editor
Expand Down Expand Up @@ -172,6 +180,8 @@ Vim has three different visual modes. They are:
- Line-wise visual mode (`V-LINE`) : `V`
- Block-wise visual mode (`V-BLOCK`) : `Ctrl-V `

**If you find yourself using visual mode operation far more often than normal mode operations, be careful. This is an anti-pattern.** It takes more keystrokes to run a visual mode operation than its normal mode counterpart. For example, if you need to delete an inner word, why use four keystrokes, `viwd` (visually highlight an inner word then delete), if you can accomplish it with just three keystrokes (`diw`)? The latter is more direct and concise. Of course, there will be times when visual modes are appropriate, but in general, favor a more direct approach.

# Command-line Mode (Cmdline or Last-Line Mode )

It's used to give vim commands. When you are in this mode, the cursor goes to the bottom of the screen where you can type in different commands.
Expand All @@ -196,12 +206,23 @@ To leave the command-line mode, you can use `<Esc>`, `Ctrl-c`, or `Ctrl-[`.

Select mode looks like Visual mode, but the commands accepted are quite different. It was created to be similar to Windows' selection mode **but with time has been less and less used**.

Typing a printable character deletes the selection and starts Insert mode.
Select mode emulates regular editor's text highlighting behavior closer than visual mode. In regular editor, after you highlight a block of text, if you type letter "a", it will delete and replace the highlighted block of text with letter "a".

### It has three modes

To enter the select mode from Normal mode, press :`gh` or `gH`
- Character-wise Select Mode `gh`
- Line-wise Select Mode `gH`
- Block-wise Select Mode `g Ctrl-h`


To enter the select mode from Normal mode, press :`gh`, `gH` or `g Ctrl-h`

To select a text, press `shift + arrow`

Getting back to Normal Mode, press `<Esc>` or `Ctrl-C` or `Ctrl-[`.

**You can't execute normal mode commands on highlighted text in select mode.**


# Ex Mode

Expand Down Expand Up @@ -254,6 +275,8 @@ Replace mode is a special case of Insert mode. You can do the same things as in

Before entering this mode, get into normal mode and put your cursor on top of the first character that you want to replace. Then press `R` to enter replace mode. Now whatever you type will replace the existing text. The cursor automatically moves to the next character just like in insert mode.

**Tip:** If you have made a small typing error in replace mode, just press backspace without exiting the replace mode. This will revert the changes made to the preceding character in replace mode.

# Virtual Replace Mode

Virtual Replace mode is similar to Replace mode, but instead of file characters you are replacing screen real estate.
Expand Down

0 comments on commit 4c5a1dc

Please sign in to comment.