Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
8

Improving navigation/workflow for IDF editing in Notepad++

asked 2014-09-04 07:40:13 -0600

updated 2017-05-03 21:39:28 -0600

Aside from syntax highlighting, which is really useful, it's sometimes very hard to navigate within a large IDF file.

When you have hundreds of classes and 40,000 lines in your IDF file it's hard to see what's going on. I was wondering if it would be possible to have either:

  • a navigation menu (similar to a table of content) that would list all object classes and you could just click on it to get to the correct section. It would basically be a link to each "!- ===== ALL OBJECTS IN CLASS: XXX ======" that would update automatically.
  • a proper way to fold your code by object and by class, just as with many programming language (I've achieved a workaround that I'll post below... But there could be a much better way I didn't see).

Have people found good ways to achieve either of those two in Notepad++ and are willing to share? Thanks.

edit retag flag offensive close merge delete

Comments

There might be a way to do the navigation menu using Function List

JasonGlazer's avatar JasonGlazer  ( 2014-12-02 07:07:27 -0600 )edit

I was not familiar with Function List, but it seems pretty easy to do it! I'll give it a shot. Thanks

Julien Marrec's avatar Julien Marrec  ( 2014-12-03 02:43:15 -0600 )edit

I've got it to work about right with Function List, but I'm not sure adding to my already somewhat long answer is the way to go for clarity purposes... What do you think?

Julien Marrec's avatar Julien Marrec  ( 2014-12-03 05:17:37 -0600 )edit

It's not that long, unless you count each picture as 1000 words...

Jamie Bull's avatar Jamie Bull  ( 2014-12-03 05:36:10 -0600 )edit

Maybe the question should be split into two parts

JasonGlazer's avatar JasonGlazer  ( 2014-12-03 05:43:38 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
8

answered 2014-09-04 08:00:30 -0600

updated 2015-08-31 04:43:57 -0600

To achieve code folding, I've found a workaround that consists in using the User Language and a macro to include opening and closing statements. It will allow folding entire classes or just objects (retaining only the object type and its Name, not the other attributes: see second image below)

  1. In the User Defined language, I've set in "Folding in comment style". Open: "#[" "#{". Close: "]#" "}#" Brackets are for objects and curly braces for classes. User Defined Language: Setting the opening and closing statements

  2. I created a macro to include those opening and closing statements in the IDF file. It's using the comments that are auto-generated when saving via the IDF editor, and I'm assuming it's in "sortedorder" considering I'm also folding the classes. The macro is basically performing a few Find and replace based on regular expression. You will need to modify the "shortcuts.xml" file located in "%appdata%\Notepad++/" and add the macro. I don't see an option to post and format code here, so I created a pastebin located here. Make sure you save shortcuts.xml while Notepad++ is closed.

  3. Then you can reopen notepad++, and under "Macro" run the "Add brackets to Eplus classes" one. Then try folding level 2 with ALT+2, then the rest with ALT+1. Code folded on two levels: classes and objects

I'll welcome any feedback/bug report, especially considering I only tested it on a couple of files, so there are some exception I might not be handling properly.


UPDATE

Navigation with anchors to classes:

For this, we'll use what is called "Function List" (thanks to @JasonGlazer for pointing out it existed)

  1. Use the shortcut [Windows] + R to bring up the run prompt, and type in : %appdata%/notepad++ Windows Explorer will open to the folder in which you'll find functionlist.xml. This is the file you need to modify, and notepad++ must be closed when you save it. So either modify with another text editor, or modify in another location then copy paste. I suggest the latter. And make a copy of your original functionlist.xml just in case, never too safe.

  2. In the <associationmap> section, add an association (see link to pastebin below). In the first association, with "userDefinedLangName", replace "EnergyPlus-JM" with whatever name you used for your user defined language. (Or delete it) The second association with "ext" associates any file with the extension .idf.

  3. In the "parsers" section, add a new parser with the id "energyplus_class" (see pastebin)

  4. After replacing/saving (with notepad++ closed), reopen notepad++. To see the "navigation pane", you need to activate the Function List pane by clicking on "View" in the navigation menu (top of windows) then "Function List", and you should see something like the following. Notice the pane on the right. Function List Pane on the right

Here is the pastebin


Update: Github repo

Go to my Github repository for the latest files and installation instructions.

edit flag offensive delete link more

Comments

1

Nothing to offer, but this is great. Thanks for sharing.

Jeff Landreth's avatar Jeff Landreth  ( 2014-09-10 22:21:01 -0600 )edit

Thanks, and you're very welcome! Don't hesitate to flag any bugs or share improvements you've found.

Julien Marrec's avatar Julien Marrec  ( 2014-09-11 09:19:35 -0600 )edit

@Julien Marrec: I am experiencing problem while setting this up. I have copied the files into the notepad++ directory with name changed. I can see the text is being highlighted but I am unable to see anything in "Navigation pane". The only thing the shows in the navigation pane is the name of the idf. Any idea why this is not appearing? Thanks

Waseem's avatar Waseem  ( 2015-08-28 09:25:41 -0600 )edit

I've edited my answer with the link to github repository I created for this. Note that "It's important to properly download the files" (see the github readme for more information)

Julien Marrec's avatar Julien Marrec  ( 2015-08-31 04:42:37 -0600 )edit
2

answered 2014-11-22 19:03:27 -0600

scottb's avatar

updated 2014-12-01 03:43:33 -0600

Would you consider learning vim?

Folding solutions are built in.

Here is a solution for folding EnergyPlus objects

:set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1

:set foldmethod=expr

To build equivalent folding solution to above you would have to specify fold markers using '{{{' and '}}}' similar to the way you are using '#['

Then use:

:set foldmethod=marker

I regularly work on IDF files that are 50k+. Vim works well

Hopefully there is an Emacs guru here to share their folding solution.

edit flag offensive delete link more

Comments

Time to brush up on elisp!

__AmirRoth__'s avatar __AmirRoth__  ( 2014-11-23 11:00:59 -0600 )edit
1

I use vim on the command line with Git for version control but I really like editing larger files with Sublime Text. I plan to create a syntax highlight file for it in the near future. If anyone else is interested, let me know. I'd love any feedback or help I can get. Also, Sublime has a great facility for snippets and I've started creating a set of them for Compact HVAC objects. This is very useful if you are creating large numbers of similar unitary systems with different input values as you can tab between key input fields.

Cheers

Eric

eayoungs's avatar eayoungs  ( 2015-04-05 15:21:42 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

6 followers

Stats

Asked: 2014-09-04 07:40:13 -0600

Seen: 2,892 times

Last updated: Aug 31 '15