Multiple cursor support in SpaceVim
Tags: vim, neovim, spacevim, emacs
Published: 2022-04-08 14:42:26

---
title: Multiple cursor support in SpaceVim
published: true
description: a powerful iedit mode to quickly edit multiple occurrences of a symbol or selection.
tags: vim, neovim, spacevim, emacs
//cover_image: https://user-images.githubusercontent.com/13142418/148374827-5f7aeaaa-e69b-441e-b872-408b47f4da04.png
---

[SpaceVim](https://spacevim.org) is a preconfigured configuration for Vim and Neovim. It provides multiple cursor supportting via `iedit` plugin which just same as `iedit-mode` of emacs.

![iedit-mode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ikilom107xx40658sq07.png)

The default key binding of iedit is `SPC s e`, `SPC` is `<Space>`. There are two mode of iedit, `iedit-normal` mode and `iedit-insert` mode. Here are the key bindings of these two modes.

#### iedit states key bindings

**State transitions:**

| Key Bindings | From             | to           |
| ------------ | ---------------- | ------------ |
| `SPC s e`    | normal or visual | iedit-Normal |

**In iedit-Normal mode:**

`iedit-Normal` mode inherits from `Normal` mode, the following key bindings are specific to `iedit-Normal` mode.

| Key Binding   | Descriptions                                                                                                                       |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `<Esc>`       | go back to `Normal` mode                                                                                                           |
| `i`           | switch to `iedit-Insert` mode, same as `i` in `Normal` model                                                                       |
| `a`           | switch to `iedit-Insert` mode, same as `a` in `Normal` model                                                                       |
| `I`           | go to the beginning of the current occurrence and switch to `iedit-Insert` mode, same as `I` in `Normal` model                     |
| `A`           | go to the end of the current occurrence and switch to `iedit-Insert` mode, same as `A` in `Normal` model                           |
| `<Left>`/`h`  | Move cursor to left, same as `h` in `Normal` model                                                                                 |
| `<Right>`/`l` | Move cursor to right, same as `l` in `Normal` model                                                                                |
| `0`/`<Home>`  | go to the beginning of the current occurrence, same as `0` in `Normal` model                                                       |
| `$`/`<End>`   | go to the end of the current occurrence, same as `$` in `Normal` model                                                             |
| `C`           | delete the characters from the cursor to the end in all occurrences and switch to iedit-Insert mode, same as `C` in `Normal` model |
| `D`           | delete the occurrences, same as `D` in `Normal` model                                                                              |
| `s`           | delete the character under cursor and switch to iedit-Insert mode, same as `s` in `Normal` model                                   |
| `S`           | delete the occurrences and switch to iedit-Insert mode, same as `S` in `Normal` model                                              |
| `x`           | delete the character under cursor in all the occurrences, same as `x` in `Normal` model                                            |
| `X`           | delete the character before cursor in all the occurrences, same as `X` in `Normal` model                                           |
| `gg`          | go to first occurrence, same as `gg` in `Normal` model                                                                             |
| `G`           | go to last occurrence, same as `G` in `Normal` model                                                                               |
| `f{char}`     | Move the cursor to the right where the `{char}` first appears in all the occurrences                                               |
| `n`           | go to next occurrence                                                                                                              |
| `N`           | go to previous occurrence                                                                                                          |
| `p`           | replace occurrences with last yanked (copied) text                                                                                 |
| `<Tab>`       | toggle current occurrence                                                                                                          |

**In iedit-Insert mode:**

| Key Bindings             | Descriptions                                                |
| ------------------------ | ----------------------------------------------------------- |
| `Ctrl-g` / `<Esc>`       | go back to `iedit-Normal` mode                              |
| `Ctrl-b` / `<Left>`      | move cursor to left                                         |
| `Ctrl-f` / `<Right>`     | move cursor to right                                        |
| `Ctrl-a` / `<Home>`      | moves the cursor to the beginning of the current occurrence |
| `Ctrl-e` / `<End>`       | moves the cursor to the end of the current occurrence       |
| `Ctrl-w`                 | delete word before cursor                                   |
| `Ctrl-k`                 | delete all words after cursor                               |
| `Ctrl-u`                 | delete all characters before cursor                         |
| `Ctrl-h` / `<Backspace>` | delete character before cursor                              |
| `<Delete>`               | delete character after cursor                               |

The `SPC s e` will select all matchs by default, if you want to select the matchs one by one, you can use `SPC s E` key binding and `Ctrl-n` to select next one.