For everyone who doesn’t use emacs or vim to write code, Notepad++ (alias: npp) is a great text editor. With the following instructions, you can adapt to Ruby on Rails, correcting a syntax highlighting issue that occurs in .erb files (viewed as HTML).
download replacement SciLexer.dll (2011)
What we’re fixing
I use Notepad++ for Ruby on Rails, and if you have done likewise, you’ve probably noticed an irritating thing with html.erb or rhtml files: syntax highlighting goes wonky when you use a single-quotation-mark ('
) within ruby on rails tags (<% %>
).
You may have tried correcting this issue by using replacing your SciLexer.dll file with the one downloaded here: therubyway.wordpress.com/2008/11/23/rails-on-notepad/,* but if your experience is like mine, an unfortunate side effect is that your code would be truncated to nothing when you tried to save it, and npp would crash.
I finally took a crack at the source for SciLexer.dll and got the results I needed. You can download my file here: http://markhamanderson.com/vault/npp-SciLexer.dll (if clicking the link doesn’t download the file, try right-clicking, then select ‘Save link as…’)
Instructions
- Download the file from the foregoing link. Rename the file to SciLexer.dll.
- Open up your Notepad++ folder (it’s usually something like C:/Program Files/Notepad++).
- The folder already contains a file named SciLexer.dll, so copy and/or rename the existing file (because we’re going to overwrite it, and you want to keep the original file on hand, just in case).
- Move the new SciLexer.dll file into your Notepad++ folder.
Note: I made this from the source for Notepad++ 5.9.3. It’s not guaranteed to work for earlier or later versions. That being the case, let’s go over how you can customize and compile your own dll file.
Customize & compile your own
- Download (and unzip) the Notepad++ source code. (Look for it here: http://notepad-plus-plus.org/download/. Be sure to get the source files, not the installer.)
- Within your extracted files, find and open scintilla/lexers/LexHTML.cxx
- Comment out the following lines (it’s anywhere that you see “
state = SCE_HBA_COMMENTLINE;
“):- 1679-1681
- 1706-1707
- 2030-2031
- 2040-2041
- Follow the instructions in scintilla/README to correctly compile your changes
- You should find your new SciLexer.dll file in the folder scintilla/bin
Thank you.