Multiline editing

In Neovim, multiline editing in Visual Mode is usually done with Visual Block Mode or Visual Line Mode. These let you edit multiple lines simultaneously.


1. Visual Block Mode (Column Editing)

Best for editing the same column across many lines.

Steps

  1. Move the cursor to the start column.
  2. Press:
Ctrl + v
  1. Use j / k (or arrow keys) to select multiple lines.
  2. Then use one of these commands:

Insert text at start of block

Shift + i

Type the text → press Esc.

Neovim inserts it on all selected lines.

Example:

Before:

apple
banana
orange

Block select first column → Shift+i → type -

After:

- apple
- banana
- orange

Append text at end of block

Shift + a

Example: add ; to end of lines.


Replace characters

Press:

r

Then type the replacement character.


Delete a column

Press:

d

2. Visual Line Mode (Whole Line Edits)

Select full lines:

Shift + v

Move up/down to select lines.

Now you can:

Indent

>

Unindent

<

Comment (if using plugin like Comment.nvim)

gc

3. Insert on Multiple Lines Without Column Alignment

Example: add // to several lines.

  1. Select lines:
Shift + v
  1. Run a normal command on them:
:normal I//

I inserts at the beginning of every selected line.


4. Useful Multiline Patterns

Add text at line end

:'<,'>normal A;

Remove first character of lines

Ctrl+v → select column → d

5. Example Workflow (Very Common)

Add console.log() before multiple JS variables.

Ctrl+v
select lines
Shift+i
console.log(
Esc

Key Idea

ModeShortcutUse case
Visual BlockCtrl+vColumn editing
Visual LineShift+vWhole line editing
VisualvCharacter selection

💡 Pro Tip: Multiline editing becomes extremely powerful when combined with Neovim plugins like vim-surround or Comment.nvim.