Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch to edit mode of vi on mac terminal [closed]

Tags:

vim

macos

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 ?

like image 214
Ahmed Avatar asked Jul 10 '13 22:07

Ahmed


People also ask

How do I edit a vi file in Mac terminal?

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.

How do I get out of insert mode in vi Mac?

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.

How do you exit insert mode and get to edit mode press?

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.


2 Answers

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.

like image 102
Justin Meiners Avatar answered Oct 18 '22 08:10

Justin Meiners


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.

like image 24
favoretti Avatar answered Oct 18 '22 09:10

favoretti