[git] How do I use Notepad++ (or other) with msysgit?

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

This question is related to git configuration text-editor notepad++ msysgit

The answer is


Here is a solution with Cygwin:

#!/bin/dash -e
if [ "$1" ]
then k=$(cygpath -w "$1")
elif [ "$#" != 0 ]
then k=
fi
Notepad2 ${k+"$k"}
  1. If no path, pass no path

  2. If path is empty, pass empty path

  3. If path is not empty, convert to Windows format.

Then I set these variables:

export EDITOR=notepad2.sh
export GIT_EDITOR='dash /usr/local/bin/notepad2.sh'
  1. EDITOR allows script to work with Git

  2. GIT_EDITOR allows script to work with Hub commands

Source


As of Git for Windows v2.15.0 (October 30th 2017) it is now possible to configure nano or Notepad++ as Git's default editor instead of vim.

During the installation you'll see the following screen:

enter image description here


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

Or, for 64-bit Windows and a 32-bit install of Notepad++:

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

Or, the following can be issued on the command line on either 32-bit or 64-bit Windows. It will pull the location of notepad++.exe from the registry and configure git to use it automatically:

FOR /F "usebackq tokens=2*" %A IN (`REG QUERY "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\notepad++.exe" /ve`) DO git config --global core.editor "'%B' -multiInst -notabbar -nosession -noPlugin"

If you wish to place the above from a .BAT or .CMD file, you must replace %A with %%A and %B with %%B


I use the approach with PATH variable. Path to Notepad++ is added to system's PATH variable and then core.editor is set like following:

git config --global core.editor notepad++

Also, you may add some additional parameters for Notepad++:

git config --global core.editor "notepad++.exe -multiInst"

(as I detailed in "Git core.editor for Windows")

And here you can find some options you may use when stating Notepad++ Command Line Options.


This works for me

git config --global core.editor C:/Progra~1/Notepad++/notepad++.exe

I am using Windows 10 and notepad++, and I was getting this error message:

line 0: syntax error near unexpected token `(' git windows

So I make the setup in this way:

git config --global core.editor 'C:/Program\ Files\ \(x86\)/Notepad++/notepad++.exe'

and it works


I used starikovs' solution. I started with a bash window and gave the commands

cd ~
touch .bashrc

Then I found the .bashrc file in windows explorer, opened it with notepad++ and added

PATH=$PATH:"C:\Program Files (x86)\Notepad++"

so that bash knows where to find Notepad++. (Having Notepad++ in the bash PATH is a useful thing on its own!) Then I pasted his line

git config --global core.editor "notepad++.exe -multiInst"

into a bash window. I started a new bash window for a git repository to test things with the command

git rebase -i HEAD~10

and the file opened in Notepad++ as hoped.


Follow these instructions,

  1. First make sure you have notepad++ installed on your system and that it is the default programme to open .txt files.

  2. Then Install gitpad on your system. Note the last I checked the download link was broken, so download it from here as explained.

Then while committing you should see your favorite text editor popping up.


git config core.editor "\"C:\Program Files (x86)\Notepad++\notepad++.exe\""

UPDATE 2015

If you unpack/install Notepad++ into c:\utils\npp\ and rename notepad++.exe to npp.exe for simplicity, then all you have to do is

git config --global core.editor c:/utils/npp/npp.exe

No wrapper scripts or other trickery. No need to have Notepad++ in PATH.


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to configuration

My eclipse won't open, i download the bundle pack it keeps saying error log Getting value from appsettings.json in .net core pgadmin4 : postgresql application server could not be contacted. ASP.NET Core configuration for .NET Core console application Turning off eslint rule for a specific file PHP Warning: Module already loaded in Unknown on line 0 How to read AppSettings values from a .json file in ASP.NET Core How to store Configuration file and read it using React Hadoop cluster setup - java.net.ConnectException: Connection refused Maven Jacoco Configuration - Exclude classes/packages from report not working

Examples related to text-editor

Find duplicates and delete all in notepad++ How to run vi on docker container? How to run a program in Atom Editor? How to call VS Code Editor from terminal / command line What is the difference between Sublime text and Github's Atom Multiple select in Visual Studio? change cursor from block or rectangle to line? Javascript button to insert a big black dot (•) into a html textarea Vim multiline editing like in sublimetext? Edit a text file on the console using Powershell

Examples related to notepad++

How to view Plugin Manager in Notepad++ How to format JSON in notepad++ CR LF notepad++ removal How to install a Notepad++ plugin offline? Find duplicates and delete all in notepad++ How to compare two files in Notepad++ v6.6.8 Notepad++ cached files location How to indent HTML tags in Notepad++ How to change background color in the Notepad++ text editor? How do I stop Notepad++ from showing autocomplete for all words in the file

Examples related to msysgit

Change the location of the ~ directory in a Windows install of Git Bash Unable to resolve "unable to get local issuer certificate" using git on Windows with self-signed certificate fatal: early EOF fatal: index-pack failed git: 'credential-cache' is not a git command How to change line-ending settings How do I exit the results of 'git diff' in Git Bash on windows? git: patch does not apply Git Bash is extremely slow on Windows 7 x64 Git - How to fix "corrupted" interactive rebase? How do I force git to use LF instead of CR+LF under windows?