简体   繁体   English

尝试在 git 中设置新编辑器

[英]Trying to setup a new editor in git

I'm trying to find a good alternative to the VI editor that comes with my git version 1.8.0.msysgit.0 installed on my windows XP box.我正在尝试为我的 windows XP 盒子上安装的 git 版本 1.8.0.msysgit.0 随附的 VI 编辑器找到一个很好的替代品。 I've looked through the forums here and tried some of their suggestions.我浏览了这里的论坛并尝试了他们的一些建议。 I must be missing something because they aren't working for me.我一定是错过了什么,因为他们不为我工作。 I've tried this from the git command line:我已经从 git 命令行尝试了这个:

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

I also tried another way that used a shell.我还尝试了另一种使用 shell 的方法。 There I created a folder named shell on the root of C: I then created a sh file named npp.sh with this content:在那里,我在 C 的根目录上创建了一个名为 shell 的文件夹:然后我创建了一个名为 npp.sh 的 sh 文件,其中包含以下内容:

#!/bin/sh
"c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*"

after that I entered this command:之后我输入了这个命令:

git config --global core.editor C:/shell/npp.sh

In both cases if I enter notepad++ on the git command line I get the message sh.exe": notepad++: command not found .在这两种情况下,如果我在 git 命令行上输入 notepad++,我都会收到消息sh.exe": notepad++: command not found

This turns out to be surprisingly difficult. 事实证明这非常困难。 /c/Program\\ Files/Notepad++/notepad++.exe executes fine from Git bash, but doesn't seem to work with git config core.editor . /c/Program\\ Files/Notepad++/notepad++.exe从Git bash可以很好地执行,但似乎不适用于git config core.editor

However, you can create a Bash alias for Notepad++ and use that as your core.editor . 但是,您可以为Notepad ++创建一个Bash 别名 ,并将其用作您的core.editor See this answer for details. 有关详细信息,请参见此答案

I encountered this issue and the git documentation enlightened me.我遇到了这个问题,git 文档启发了我。

https://docs.github.com/en/get-started/getting-started-with-git/associating-text-editors-with-git https://docs.github.com/en/get-started/getting-started-with-git/associating-text-editors-with-git

The section under "Using Notepad++ as your editor" provided the answer. “使用 Notepad++ 作为您的编辑器”下的部分提供了答案。

Run the following in Git Bash and you're away.在 Git Bash 中运行以下命令,你就走了。

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

If you want to open up the global git config file after setting up notepad++ use this:如果要在设置 notepad++ 后打开全局 git 配置文件,请使用:

$ git config --global -e

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM