Ruby on Rails on Notepad++

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 (<% %>).

What we see in Notepad++
We'd rather see something more like this

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

  1. Download the file from the foregoing link. Rename the file to SciLexer.dll.
  2. Open up your Notepad++ folder (it’s usually something like C:/Program Files/Notepad++).
  3. 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).
  4. 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

  1. 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.)
  2. Within your extracted files, find and open scintilla/lexers/LexHTML.cxx
  3. Comment out the following lines (it’s anywhere that you see “state = SCE_HBA_COMMENTLINE;“):
    • 1679-1681
    • 1706-1707
    • 2030-2031
    • 2040-2041
  4. Follow the instructions in scintilla/README to correctly compile your changes
  5. You should find your new SciLexer.dll file in the folder scintilla/bin

* Maybe the blog at ‘therubyway.wordpress’ has some good value, but I’m disappointed with it. I posted a comment on the aforementioned post, requesting assistance with the dll back in May, and every time I’ve been back to check up on it, I see that it’s still awaiting moderation. I suppose that the dll file there hasn’t been updated since 2008 and consequently only works for an earlier version of Notepad++.

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *