# Notepad++ with Crystal

**URL:** <https://forum.crystal-lang.org/t/notepad-with-crystal/1359>\
**Category:** Offtopic\
**Created:** [November 13, 2019, 7:40pm UTC](https://forum.crystal-lang.org/t/notepad-with-crystal/1359 "2019-11-13T19:40:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![girng\_github](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/girng_github/32/571_2.png) [@girng\_github](https://forum.crystal-lang.org/u/girng_github)\
**Post date:** [November 13, 2019, 7:40pm UTC](https://forum.crystal-lang.org/t/notepad-with-crystal/1359/1 "2019-11-13T19:40:08Z")

</div>

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.

 ![](https://i.gyazo.com/d3d6cda54cfc50c640db51fa6548d860.gif)

## Installation Steps

- Download a **64-bit version** of [Notepad++](https://notepad-plus-plus.org/downloads/).
- Install @faustinoaq’s awesome [Crystal Installer for Windows](https://github.com/faustinoaq/crystal-windows-installer)
- In Notepad++, go to `Plugins` -\> `Plugins Admin`, search for `NppExec` and install. Restart.
- In Notepad++, go to `Plugins` -\> `NppExec` -\> `Execute`, and copy this code into the box:

```auto
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 it `CrystalFormatter` (or whatever you like).
- Now go to `Plugins` -\> `NppExec` -\> `Advanced Options` and under `Associated scripts`, click `CrystalFormatter`. Then click `Add/Modify`, then check `Place to the Macro submenu`.  
[Example](https://i.gyazo.com/79f308e107964e2e8dfc17bcb0e65ee6.png). 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 by `CrystalFormatter`).
- Click `Modify` and set the appropriate hotkey options (mark `Ctrl` and choose `S` from the dropdown).
- Click `OK` to save the new shortcut settings and `Close` the _Shortcut Mapper…_ . [Source](https://superuser.com/a/1295528)

## Crystal Syntax Highlighting

- Download the XML file from [https://gist.github.com/apfeltee/dec1681ed47977b1b6b0](https://gist.github.com/apfeltee/dec1681ed47977b1b6b0)
- In Notepad++, go to `Language` -\> `Define your language...` click on `Import...` and select the `.xml` file.
- Now you can select `Crystal` from the `Language` menu.

## Quality Of Life Features

- `Settings` -\> `Preferences...` , on the left menu select `Language`, change `Tab size` to **2** (matches Crystal’s formatter).
- `Settings` -\> `Preferences...`, on the left menu select `MISC.`, then check `Update silently`. This is important for format on save to work smoothly.

---

<div class="post-metadata">

**Author:** ![faustinoaq](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/faustinoaq/32/1126_2.png) [@faustinoaq](https://forum.crystal-lang.org/u/faustinoaq)\
**Post date:** [March 31, 2020, 9:53am UTC](https://forum.crystal-lang.org/t/notepad-with-crystal/1359/2 "2020-03-31T09:53:31Z")

</div>

This is Awesome! ✨ 😄

Thank you so much for this 👍
