I am new to mac, trying to edit a .gitignore file from the macbook terminal, I type
vi .gitignore
it opens the file but not letting me switch to edit mode. How does vi switches mode on mac ?
In the Terminal app on your Mac, invoke a command-line editor by typing the name of the editor, followed by a space and then the name of the file you want to open. If you want to create a new file, type the editor name, followed by a space and the pathname of the file.
vi mode has two submodes: insert mode and command mode. The default mode is insert. You can toggle between the modes by pressing Esc; alternatively, in command mode, typing a (append) or i (insert) will return you to insert mode.
To come out of the insert mode, press the Esc key, which will take you back to the command mode. Hint − If you are not sure which mode you are in, press the Esc key twice; this will take you to the command mode. You open a file using the vi editor.
On Mac you can more correctly type vim
(Vi Improved) instead :)
Same as everywhere, i
switches to "INSERT" mode and ESC
switches back to command mode.
A good learning resource for Vim is included in Mac. Simply type vimtutor
and it will teach you quickly how to use vim effectively.
Another editing option on mac is nano
it is a command line text editor that is much easier for those familiar with TextEdit/Notepad.
Same as everywhere. i
to insert. Esc
to go back to command mode, :wq
to save and quit.
By the way, if you're uncomfortable with vi
, try Sublime Text 2, I love it :) It's GUI based, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With