2

Git includes Vi in its Git Bash shell on Windows through MinGW64. I'm not a Vi user, so Git really screws things up for me when it launches Vi. It usually ends in me forcefully closing the terminal, deleting the clone, and then re-cloning (because it wastes so much time trying to fix the mess).

I'd like to use Vi in Emacs mode if there is such a thing. Other editors, like Notepad++ and Visual Studio have similar modes (or plugins to provide them), so I'm guessing Vi probably has it too.

Does Vi have an Emacs mode of operation? If so, how do I tell Vi to behave like Emacs? Or, how do I tell Git to provide me with an Emacs-like editor?

  • 3
    Are you thinking about the editor that is launched to edit the commit messages? – Kusalananda May 26 '17 at 11:51
  • @Kusalananda - I believe the answer is yes. I can post MinGW64's /usr/bin if desired. But its slim picking's as far as programs go; and I don't see Emacs or one of its knock-offs. There's not much there (I guess that explains why Git insists on using Vi). – user56041 May 26 '17 at 11:54
  • 2
    @Philippos - Yeah, editors are like religion. I try to avoid the Emacs/Vi debates. Some of the history (for me): when I was in college our CompSci instructor introduced us to both Emacs and Vi. I remember trying them both, and I was perplexed I had to do something special to edit text in a text editor when using Vi. I wrote-off Vi as poorly engineered, and I've been using Emacs ever since (25 years or so). – user56041 May 26 '17 at 12:26
  • 2
    Forcefully closing a terminal, deleting and re-cloning is a ridiculously heavy handed approach. You don't need to learn Vi to write commit messages. All you need to know is i (for insert mode), esc (exit insert mode) and :wq (write and quit). Once you're in insert mode, you can ignore all of Vi's other features and use it like a normal editor if you so wish. You can type like normal, and use arrow keys to navigate. As an aside, calling Vi "poorly engineered" isn't a great way to avoid Emacs/Vi debates. "I personally don't like it" would probably be considered more neutral! – JBentley May 27 '17 at 12:52
  • 1
    Thanks @RubberDuck. I'm very familiar with many Git commands. Like millions of others, we all have problem with simple tasks. For example, here is 4 million people having trouble with the simple task of updating a fork: How do I update a GitHub forked repository? And here's 50000 people who had trouble with a simple task of reset: Clean up a fork and restart it from the upstream. When problems affect millions of users, the problem is with the tool, not the users. – user56041 May 28 '17 at 0:15
31

You can't do it that way. vi is vi and emacs is emacs. If you are not happy with the default editor, do

git config --global core.editor path-to-emacs.exe-on-your-machine

You can install emacs separately, it doesn't need to be part of your git bash.

  • Thanks @Philippos. I probably should have stated in the question.... GNU Emacs | Download & installation tells me to pacman -S mingw-w64-x86_64-emacs. But it appears Git Bash's package manager is broken out of the box: bash: pacman: command not found. I can post the contents of /usr/bin if you would like to see it. – user56041 May 26 '17 at 12:19
  • 3
    I think you're looking at the directions for msys2. The paragraph right above it gives mirrors to exe installers. – jmathew May 26 '17 at 14:05
7

To build upon @Philippos' answer, it doesn't make sense to try to configure vim to work like emacs, you should set git to use your preferred editor instead. I see from the comments that you don't have emacs installed, do you have another text editor installed that you could use for this?

For example, if you use Notepad++ you can use:

git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

You should be able to do something similar with any text editor, though finding the correct command to use might take some searching.

  • I'd say from the way he worded the question that he specifically wants Emacs, or something with an Emacs mode. – JBentley May 27 '17 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy