How do I copy one character at a time from the line above or below while typing in insert mode?
Answer
<C-e> / <C-y> (insert mode)
Explanation
In insert mode, <C-e> copies the character directly below the cursor (from the next line) and <C-y> copies the character directly above (from the previous line). Holding either key streams characters column by column from the adjacent line — without leaving insert mode or disrupting the current line.
How it works
- The character is taken from the same column position on the adjacent line
- Each keypress copies exactly one character and advances the cursor one position
- The adjacent line is not modified
- Note: in normal mode,
<C-e>and<C-y>scroll the viewport — this is a separate, insert-mode-only behavior
Example
You have two similar lines and are typing the second:
const CONFIG_PATH = "/etc/app/config.json";
const LOG_PATH = "
With the cursor after the opening quote, pressing <C-y> repeatedly copies /etc/app/ character by character from the line above, saving you from retyping the common prefix.
Tips
- Unlike
<C-n>/<C-p>word completion, these keys copy raw characters with no menu or selection step - Works across line endings: if the line above is shorter, Vim stops copying when it runs out of characters
- Combine with
<C-e>to pull from below when writing header/footer pairs - Great for duplicating URLs, import paths, or any repeated structural prefix