[Vi/Vim] How to move cursor to the start of a line

If you are using Vi/Vim editor to read a text file and want to move your cursor to the first character of the line i.e. at the start of the line, you can make use of the ^ (caret) symbol on your keyboard,

  1. Open your file in vi editor - vi myFile.txt
  2. Now be on the line you want to move to the start of.
  3. Press ^ character on your keyboard (mostly should Shift + 6 key)
  4. You would see your cursor moves at the first char of the line.

⚠️ Make sure that you are not in Insert Mode, or else you would see that the character ^ will get added to the text and this shortcut won't work, press Esc (Escape) key to come out of Insert Mode and then try the command.

⚡️ On Windows Operating system keyboard you can make use of Home and End keys as well to get this behavior.

Usecase: Imagine someone is working a terminal on a file that does not have a line break (\r \n) then it would be very difficult to get to the start of the line using the right and left arrow keys!

Hashtags: #vi #vim #viMacOs #macOS #viTips #viCommands