Just kidding, it works on all OS as well. Just configure the correct directory upon setting this method.
Vim comes as a package when installing Git even though you choose other text editor during installation.
You invoke vim as vi <filename>
in Git Bash cli.
Short and sweet. What about the other editors?
For GNU nano:
nano <filename>
For Notepad:
notepad <filename>
For Notepad++:
start notepad++ <filename>
For
<your favourite editor>
:start <your favourite editor> <filename>
Isn't very efficient it seems. You can however change the main editor via git config. But only one main editor is allowed at once.
Worry not, here's an efficient way around it to use all editors in Git Bash:
Add Permanent Alias in Git Bash
Run Git Bash as administrator.
Open aliases.sh
$ cd /etc/profile.d
$ vi aliases.sh
Add alias in aliases.sh. For example, we add npp as an alias for Notepad++:
# --show-control-chars: help showing Korean or accented characters
alias ls='ls -F --color=auto --show-control-chars'
alias ll='ls -l'
alias npp='/c/Program\ Files/Notepad++/notepad++.exe'
p/s: Use \
to escape spaces in the directory.
Add as many other editors as you like in the aliases.sh file. Just follow the format:
alias <YourAlias>='/YourProgramDirectory/YourEditor.exe'
Save the settings, close Git Bash and reopen it to activate the new configuration. Voila!
If it does not activated by chances in the future, source it and it will be activated again:
$ cd /etc/profile.d
$ source aliases.sh
As a bonus, this method also works to add any linux commands as alias too. For example, instead of clear
, you can alias it as cls.
cls=`clear`
That's it folks, happy days!
So what are your favourite editor? Comment down below.
Cheers!
Top comments (0)