How do I copy characters from the line above or below the cursor while staying in insert mode?
Answer
<C-y> (above) / <C-e> (below)
Explanation
In insert mode, <C-y> inserts the character from the same column one line above, and <C-e> inserts the character from the same column one line below. Each keypress copies exactly one character; hold the key or repeat to copy a run of characters column by column.
This is invaluable when you are typing a line that closely mirrors an adjacent line — instead of copying the whole line and then editing it, you can fill in only the parts you need directly from the neighbor.
How it works
<C-y>— insert-mode shortcut, copies the character directly above the cursor<C-e>— insert-mode shortcut, copies the character directly below the cursor- Each press advances the cursor one column and inserts one character
- If the neighbor line is shorter than the current column position, the command is silently ignored
Example
hello, world!
|
With cursor at the | position on a blank line, pressing <C-e> four times produces:
hello, world!
worl
Tips
- Useful for duplicating config values, aligning similar lines, or copying a URL path one segment at a time
- Pair with
<C-p>/<C-n>completion for a fully keyboard-driven typing workflow without leaving insert mode - These bindings also work in the command line:
<C-y>in command mode copies the character above the cursor from the current buffer at that column