What is the difference between 0 and ^ for moving to the beginning of a line?
Answer
^ vs 0
Explanation
Vim has two distinct motions for moving to the start of a line: 0 goes to column 1 (the absolute start), while ^ goes to the first non-blank character. Understanding when to use each is key to efficient horizontal navigation in indented code.
How it works
0— move to column 1 (absolute beginning of line)^— move to the first non-blank character_— same as^(alternative mapping)- With indented code,
^is almost always what you want
Example
function hello() {
0 → ^ ^
| |
col 1 ^ (first non-blank)
Tips
d^deletes from cursor to the first non-blank — useful for changing indentationd0deletes from cursor to column 1 — removes all leading contentIenters insert mode at^position (first non-blank)0thenwis sometimes easier than^for muscle memory- Some users remap
0to toggle between column 1 and first non-blank