'How can I turn off vim in terminal of Mac?
I was trying to setup Mongo DB Community on my Mac(m1). I installed Home-brew first and followed the install instruction of the Mongo DB. However I could not run the command brew and I found that it was the problem that I didn't set up the Path in the zshell. So I tried it with my terminal but It just got stuck in this here. I tried to escape it with the :wq, :q! commands and it works. but whenever I restart the terminal it goes right back to this screen not to main screen. How can I solve this problem? plz help :( (Im trying to learning so I'm not familiar with the terminal and codes stuffs)

Solution 1:[1]
You are in this situation because you typed the wrong command in the terminal and I suspect it is because you copy-pasted it instead of typing it out.
Your command is helpfully spelled out in the title bar of the window:
$ vi ~/.zshrcexport PATH=/opt/homebrew/bin:
Judging by the content of the buffer, it is almost certainly truncated and the actual command was probably:
$ vi ~/.zshrcexport PATH=/opt/homebrew/bin:$PATH
So what's wrong with that command? Everything, actually.
For starter, it should have been:
$ vi ~/.zshrcwith
~/.zshrcbeing your shell's main configuration file.Everything after that shouldn't be here.
Vim, which is the program providing the
vicommand, takes one or more filenames as arguments. With that command, you told Vim to open two files:~/.zshrcexport PATH=/opt/homebrew/bin:$PATH- the former is the one shown in your screenshot,
- the latter is not shown but it is likely to have a rather long name,
- neither of those files are supposed to exist.
How to get out of that mess?
Assuming you are in the situation shown by that screenshot, do the following:
- Press the
esckey to make sure you are in what is called "normal mode" in Vim. - Press the
:key to enter "command-line mode". - Type
qa!, then press thereturnor??key.
- Press the
At that point you should be outside of Vim and in your shell. It is time to delete the non-wanted files you created with these two commands, each followed by a press on the
returnor??key:$ rm ~/.zshrcexport $ rm PATH=/opt/homebrew/bin:$PATHNow you should finally be able to edit your shell's configuration file but I recommend you don't do it with the
vicommand.nanois a much simpler editor that doesn't require as much learning.Open the configuration file in
nanowith:$ nano ~/.zshrcMove around with your cursor keys until you find the right spot, just like in a regular text editor. The file is probably empty anyway.
Type that "export" line:
export PATH=/opt/homebrew/bin:$PATHPress
control+Xto quit, as instructed at the bottom of the screen.Press the appropriate key when asked if you want to write the file.
Avoid
viorvimin the future until you actually have or want to learn it.
As for why you end up in Vim when you open a new terminal window I have no clue. Maybe another one of your mistakes?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | romainl |
