My First File in Vim
Today I created and read my first file using Vim, and it was more fun than I expected!
What I did:
Opened Vim with
vim myfile.txtPressed
ito enter Insert Mode and typed three lines of textPressed
Escto return to Command ModeTyped
:wqto save and quitRan
cat myfile.txtto confirm the content was saved (screenshot attached below)
What I learned about Vim’s modes:
Vim isn’t like a normal text editor, because it has different modes. When you open a file you start in Command (Normal) Mode, where keys are commands, not text. That’s why typing right away doesn’t work. Pressing i switches to Insert Mode, where you can actually type. Pressing Esc takes you back to Command Mode, where commands like :wq (write and quit) are used to save and exit. Once I understood that Esc is the way back to Command Mode, Vim stopped feeling confusing.
Have you used Vim before? What was your first “how do I exit this?!” moment? Tell me in the comments!