How do I move the cursor to a specific column on the current line?
Answer
{count}|
Explanation
The | command moves the cursor to a specific screen column on the current line. With a count, it goes directly to that column number.
How it works
{count}|moves to column N (e.g.,20|moves to column 20)|without a count moves to column 1- Columns are 1-indexed
Example
const value = calculateResult(x, y);
Pressing 15| moves the cursor to column 15, which is the = character.
Tips
- Useful for aligning text or navigating fixed-width formats
- Works with operators:
d20|deletes from cursor to column 20 virtcol('.')in Vimscript returns the current virtual column- Different from
0{count}lbecause|counts from column 1