How do I move the cursor past the end of a line or into empty space in Vim?
Answer
:set virtualedit=all
Explanation
By default, Vim constrains the cursor to actual characters in the buffer — you cannot move past the end of a line or into columns that have no text. :set virtualedit=all removes this restriction, letting you place the cursor anywhere on the screen, even in virtual (non-existent) space. This is particularly useful for column-based editing and ASCII art.
Modes
| Value | Effect |
|---|---|
virtualedit= |
(empty, default) Cursor stays on real characters only |
virtualedit=all |
Cursor can go anywhere — past end of line, into blank space |
virtualedit=block |
Free cursor only in Visual Block mode (<C-v>) |
virtualedit=insert |
Free cursor in Insert mode |
virtualedit=onemore |
Allow cursor one position past the last character (useful for $ behavior) |
Example
:set virtualedit=all
Now you can:
- Move the cursor past the end of short lines to align text in columns
- Position the cursor in empty space and type — Vim auto-fills with spaces
- Create ASCII art or tables without worrying about line lengths
Common use: block mode only
Most users prefer virtualedit=block — it enables free cursor movement only in <C-v> block selection mode, which makes rectangular edits much easier without affecting normal editing:
:set virtualedit=block
Tips
- With
virtualedit=all, typing in virtual space inserts real spaces to fill the gap virtualedit=onemoreis popular for making$in normal mode place the cursor ON the last character rather than before it- Multiple values can be combined:
:set virtualedit=block,onemore :set virtualedit=(empty) restores default behavior