如何使用记事本++(或其他)与msysgit? [英] How do I use Notepad++ (or other) with msysgit?

查看:218
本文介绍了如何使用记事本++(或其他)与msysgit?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用记事本++(或任何其他编辑器除了vim)与msysgit?



我尝试以下所有无效:

  git config --global core.editor C:\Program Files\Notepad ++ \\\
otepad ++。exe

git config --global core.editorC:\Program Files \ Notepad ++ \\\
otepad ++。exe

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

git config --global core.editor C:\\Program Files\\Notepad ++ \\\\
otepad ++。exe


解决方案

更新2010-2011:



zumalifeguard 解决方案(upvoted)比原来的更简单,因为它不再需要shell包装器脚本。



正如我在如何设置编辑器以在Windows上使用Git?解释,我喜欢一个包装器,因为它更容易尝试和切换编辑器,或更改一个编辑器的路径,而不必再次注册一个 git config

但这只是我。






其他信息:以下解决方案也将与 Cygwin 配合使用。 zuamlifeguard的解决方案不会。








原始答案。



以下:

  C:\prog\git> git config --global core.editor C:/prog/git/npp.sh 

C:/prog/git/npp.sh:
#!/ bin / sh
c:/ Program Files / Notepad ++ / notepad ++。exe-multiInst$ *

工作。这些命令被解释为shell脚本,因此将任何窗口命令集合包装在 sh 脚本中。

(As 魅力 注释:记住保存您的 .sh 文件与Unix风格行尾或接收神秘的错误消息!



有关SO问题的详细信息如何设置编辑器工作在Windows上使用Git?



注意' -multiInst '选项,



注意,如果你在 Cygwin 上使用Git,并且希望使用Cygwin的记事本),然后 scphantm 使用记事本++中说明对于Cygwin中的Git ,您必须意识到:


git 正在传递 cygwin 路径和 npp 不知道该怎么办


所以脚本在这种情况下是:

 #!/ bin / sh 
C:/ Program Files(x86)/ Notepad ++ / notepad ++。exe-multiInst -notabbar -nosession -noPlugin$(cygpath -w$ *)

多行可读性:



/ Program Files(x86)/ Notepad ++ / notepad ++。exe-multiInst -notabbar \\ \\
-nosession -noPlugin$(cygpath -w$ *)

$(cygpath -w$ *) 是重要的部分。



Val 注释(然后删除)您不应该使用 -notabbar 选项:


在rebase期间禁用选项卡并不好,但是对常规记事本可用性code> -notab 成为默认设置,您必须设置>首选项>常规> TabBar>隐藏>取消选中每次在rebase后启动记事本。这是地狱。你推荐了地狱。


所以使用:

C:/ Program Files(x86)/ Notepad ++ / notepad ++。exe-multiInst -nosession -noPlugin$(cygpath  - w$ *)

即:


$ b b

 #!/ bin / sh 
C:/ Program Files(x86)/ Notepad ++ / notepad ++。exe-multiInst -nosession \
-noPlugin$(cygpath -w$ *)






如果你想在带有空格的路径中放置脚本' npp.sh '(如
' c:\program files\ ... '),您有三个选项:




How do I use Notepad++ (or any other editor besides vim) with msysgit?

I tried all of the following to no avail:

git config --global core.editor C:\Program Files\Notepad++\notepad++.exe

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

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

git config --global core.editor C:\\Program Files\\Notepad++\\notepad++.exe

解决方案

Update 2010-2011:

zumalifeguard's solution (upvoted) is simpler than the original one, as it doesn't need anymore a shell wrapper script.

As I explain in "How can I set up an editor to work with Git on Windows?", I prefer a wrapper, as it is easier to try and switch editors, or change the path of one editor, without having to register said change with a git config again.
But that is just me.


Additional information: the following solution will also works with Cygwin. zuamlifeguard's solution will not.


Original answer.

The following:

C:\prog\git>git config --global core.editor C:/prog/git/npp.sh

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

does work. Those commands are interpreted as shell script, hence the idea to wrap any windows set of commands in a sh script.
(As Franky comments: "Remember to save your .sh file with Unix style line endings or receive mysterious error messages!")

More details on the SO question How can I set up an editor to work with Git on Windows?

Note the '-multiInst' option, for ensuring a new instance of notepad++ for each call from Git.

Note also that, if you are using Git on Cygwin (and want to use Notepad++ from Cygwin), then scphantm explains in "using Notepad++ for Git inside Cygwin" that you must be aware that:

git is passing it a cygwin path and npp doesn't know what to do with it

So the script in that case would be:

#!/bin/sh
"C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$(cygpath -w "$*")"

Multiple lines for readability:

#!/bin/sh
"C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar \
  -nosession -noPlugin "$(cygpath -w "$*")"

With "$(cygpath -w "$*")" being the important part here.

Val commented (and then deleted) that you should not use -notabbar option:

It makes no good to disable the tab during rebase, but makes a lot of harm to general Notepad usability since -notab becomes the default setting and you must Settings>Preferences>General>TabBar> Hide>uncheck every time you start notepad after rebase. This is hell. You recommended the hell.

So use rather:

#!/bin/sh
"C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -nosession -noPlugin "$(cygpath -w "$*")"

That is:

#!/bin/sh
"C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -nosession \
  -noPlugin "$(cygpath -w "$*")"


If you want to place the script 'npp.sh' in a path with spaces (as in 'c:\program files\...',), you have three options:

  • Either try to quote the path (single or double quotes), as in:

    git config --global core.editor 'C:/program files/git/npp.sh'
    

  • or try the shortname notation (not fool-proofed):

    git config --global core.editor C:/progra~1/git/npp.sh
    

  • or (my favorite) place 'npp.sh' in a directory part of your %PATH% environment variable. You would not have then to specify any path for the script.

    git config --global core.editor npp.sh
    

  • Steiny reports in the comments having to do:

    git config --global core.editor '"C:/Program Files (x86)/Git/scripts/npp.sh"'
    

这篇关于如何使用记事本++(或其他)与msysgit?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆