Hello everyone! I finally got format on save to work with Notepad++! I’m extremely excited and wanted to create a guide. Hopefully it saves future developers some time, it took me forever haha.
Installation Steps
- Download a 64-bit version of Notepad++.
- Install @faustinoaq’s awesome Crystal Installer for Windows
- In Notepad++, go to
Plugins
->Plugins Admin
, search forNppExec
and install. Restart. - In Notepad++, go to
Plugins
->NppExec
->Execute
, and copy this code into the box:
npp_save
"C:\Program Files (x86)\Crystal\crystal.bat" & cd $(CURRENT_DIRECTORY) & crystal tool format $(FILE_NAME)
npp_open $(FULL_CURRENT_PATH)
- Then, click on
Save...
and name itCrystalFormatter
(or whatever you like). - Now go to
Plugins
->NppExec
->Advanced Options
and underAssociated scripts
, clickCrystalFormatter
. Then clickAdd/Modify
, then checkPlace to the Macro submenu
.
Example. Restart. - And voila! Under the
Macro
menu,CrystalFormatter
appears!
Setup Format On Save (Ctrl+S)
- Open Settings → Shortcut Mapper… .
- On the Main menu tab, highlight the entry for “Save”. Click
Clear
at the bottom of the window to clear the hotkey settings for that item ( Ctrl+S ). - Select the Plugin commands tab. Scroll down and highlight the entry for your
NppExec
command script (identified byCrystalFormatter
). - Click
Modify
and set the appropriate hotkey options (markCtrl
and chooseS
from the dropdown). - Click
OK
to save the new shortcut settings andClose
the Shortcut Mapper… . Source
Crystal Syntax Highlighting
- Download the XML file from https://gist.github.com/apfeltee/dec1681ed47977b1b6b0
- In Notepad++, go to
Language
->Define your language...
click onImport...
and select the.xml
file. - Now you can select
Crystal
from theLanguage
menu.
Quality Of Life Features
-
Settings
->Preferences...
, on the left menu selectLanguage
, changeTab size
to 2 (matches Crystal’s formatter). -
Settings
->Preferences...
, on the left menu selectMISC.
, then checkUpdate silently
. This is important for format on save to work smoothly.