Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Update 2010-2011:</p> <p><a href="https://stackoverflow.com/users/75129/zumalifeguard">zumalifeguard</a>'s <a href="https://stackoverflow.com/questions/1634161/how-do-i-use-notepad-or-other-with-msysgit/2486342#2486342">solution</a> (upvoted) is simpler than the original one, as it doesn't need anymore a shell wrapper script.</p> <p>As I explain in "<a href="https://stackoverflow.com/a/773973/6309">How can I set up an editor to work with Git on Windows?</a>", <strong>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 <code>git config</code> again</strong>.<br> But that is just me.</p> <hr> <p><em>Additional information</em>: the following solution works with <strong>Cygwin</strong>, while the zuamlifeguard's solution does not.</p> <hr> <p>Original answer.</p> <p>The following:</p> <pre class="lang-sh prettyprint-override"><code>C:\prog\git&gt;git config --global core.editor C:/prog/git/npp.sh C:/prog/git/npp.sh: #!/bin/sh "c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*" </code></pre> <p>does work. Those commands are interpreted as shell script, hence the idea to wrap any windows set of commands in a <code>sh</code> script.<br> (As <a href="https://stackoverflow.com/users/412549/franky">Franky</a> <a href="https://stackoverflow.com/questions/1634161/how-do-i-use-notepad-or-other-with-msysgit/1635493#comment51287812_1635493">comments</a>: "Remember to save your <code>.sh</code> file with Unix style line endings or receive mysterious error messages!")</p> <p>More details on the SO question <a href="https://stackoverflow.com/q/10564/6309">How can I set up an editor to work with Git on Windows?</a></p> <p>Note the '<code>-multiInst</code>' option, for ensuring a new instance of notepad++ for each call from Git.</p> <p>Note also that, if you are using Git on <strong>Cygwin</strong> (and want to <a href="https://superuser.com/questions/168971/use-notepad-from-cygwin-without-having-the-shell-wait-for-an-exit-code">use Notepad++ from Cygwin</a>), then <a href="https://stackoverflow.com/users/425715/scphantm">scphantm</a> explains in "<a href="https://stackoverflow.com/q/10209660/6309">using Notepad++ for Git inside Cygwin</a>" that you must be aware that:</p> <blockquote> <p><code>git</code> is passing it a <code>cygwin</code> path and <code>npp</code> doesn't know what to do with it</p> </blockquote> <p>So the script in that case would be:</p> <pre class="lang-sh prettyprint-override"><code>#!/bin/sh "C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$(cygpath -w "$*")" </code></pre> <p>Multiple lines for readability:</p> <pre class="lang-sh prettyprint-override"><code>#!/bin/sh "C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar \ -nosession -noPlugin "$(cygpath -w "$*")" </code></pre> <p>With <strong><code>"$(cygpath -w "$*")"</code></strong> being the important part here.</p> <p><a href="https://stackoverflow.com/users/1083704/val">Val</a> <a href="https://stackoverflow.com/questions/1634161/how-do-i-use-notepad-or-other-with-msysgit/1635493?noredirect=1#comment29027434_1635493">commented</a> (and then deleted) that you should not use <code>-notabbar</code> option:</p> <blockquote> <p>It makes no good to disable the tab during rebase, but makes a lot of harm to general Notepad usability since <code>-notab</code> becomes the default setting and you must <code>Settings&gt;Preferences&gt;General&gt;TabBar&gt; Hide&gt;uncheck</code> every time you start notepad after rebase. This is hell. You recommended the hell.</p> </blockquote> <p>So use rather:</p> <pre class="lang-sh prettyprint-override"><code>#!/bin/sh "C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -nosession -noPlugin "$(cygpath -w "$*")" </code></pre> <p>That is:</p> <pre class="lang-sh prettyprint-override"><code>#!/bin/sh "C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -nosession \ -noPlugin "$(cygpath -w "$*")" </code></pre> <hr> <p>If you want to place the script '<code>npp.sh</code>' in a path with spaces (as in '<code>c:\program files\...</code>',), you have three options:</p> <ul> <li><p>Either try to quote the path (single or double quotes), as in:</p> <pre class="lang-sh prettyprint-override"><code>git config --global core.editor 'C:/program files/git/npp.sh' </code></pre></li> <li><p>or try the <a href="https://stackoverflow.com/a/892568/6309">shortname notation</a> (not fool-proofed):</p> <pre class="lang-sh prettyprint-override"><code>git config --global core.editor C:/progra~1/git/npp.sh </code></pre></li> <li><p>or (my favorite) place '<code>npp.sh</code>' in a directory part of your <code>%PATH%</code> environment variable. You would not have then to specify any path for the script.</p> <pre class="lang-sh prettyprint-override"><code>git config --global core.editor npp.sh </code></pre></li> <li><p><a href="https://stackoverflow.com/users/367796/steiny">Steiny</a> reports <a href="https://stackoverflow.com/questions/1634161/how-do-i-use-notepad-or-other-with-msysgit/1635493#comment48770355_1635493">in the comments</a> having to do:</p> <pre class="lang-sh prettyprint-override"><code>git config --global core.editor '"C:/Program Files (x86)/Git/scripts/npp.sh"' </code></pre></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload