Issue 108 – August 6, 2022

VS Code for the win

Hey there,

It’s Robin from CFD Engine & I’m back on one of my favourite subjects this week, the humble text editor 🤓

I recently found out that my recommended editor is going away, so I’m here with an alternative, plus a couple of extensions for it that you might like.

Let’s go…

Background

OpenFOAM is all about editing text files (& Googling error messages) & if you’re still using the editor that shipped with your operating system then you’re due an upgrade.

Windows Notepad is not the tool for this job.

I suggest grabbing a code editor instead. They’re loaded with neat features like syntax highlighting, multiple cursors, split screens & bracket matching & they really can improve your day-to-day OpenFOAM experience (not to mention giving you a nice productivity bump too).

I used to recommend Atom, an open-source code editor from GitHub, but they recently announced its demise 😢 so it’s time to update my recommendation.

Thankfully there’s a ready-made replacement waiting in the wings…

Meet VS Code

Atom’s development has been slowing ever since Microsoft bought GitHub and chose to focus their efforts on their similar/competing product, Visual Studio Code, instead.

Like Atom, VS Code is open-source, available on all the main operating systems, has a ton of extensions, is highly customisable and free to use.

Whereas Atom was primarily a text editor, VS Code is more of a integrated development environment, meaning it does much more than just edit text files.

It has all of the nice features I mentioned earlier, plus plenty of functionality you’ll never need. Don’t be overwhelmed, just use the bits you want & ignore the rest (like we do with OpenFOAM).

Extensions

Having said that, there’s a huge marketplace of extensions offering even more functionality. Here are a few that I’ve found useful & that you might want to check out when/if you give VS Code a try:

Live Share

The Live Share extension pack allows you to share your editor with other VS Code users & edit files collaboratively. Much better than faffing about with a screenshare, plus it even includes the option for audio chat.

Great for case checking, troubleshooting & holding training sessions when one or more team members are working remotely.

Bookmarks

A nifty extension that allows you to define named bookmarks in your files so that you can quickly jump to a given point. Handy for jumping into the middle of your snappyHexMeshDict while developing a mesh recipe or returning to a particular section in a long log file.

SSH

There are loads of extensions that help when working on remote machines &/or remote filesystems, but one of the most useful (for us) is the SSH extension.

This one lets us edit files on a remote machine as though they were local, all without having to install anything extra on the remote machine.

Super-handy when IT won’t install new things on the cluster.

Bits & Bobs

There’s much more to explore, including Python tools for editing ParaView scripts, plus tonnes of themes & other cool customisations.

There are even some OpenFOAM-specific extensions that are still at an early stage, but worth a peak.

VS Codium

A quick side note: the VS Code binaries from Microsoft include telemetry which sends usage analytics back to the mothership 🤔

If you’re not comfortable with this, then you could try VS Codium – a clean build of VS Code that doesn’t include telemetry.

It’s not as easy to install extensions in this version, but it’s there if you want it.

Over to you

Chances are you already have a favourite editor (plus a favourite monospaced font and a favourite colour scheme). I’m not here to mess with any of that, but if you’re not happy with your text editor (or worse, you’re using Windows Notepad) then check out VS Code (or VS Codium) & see if it makes editing OpenFOAM dictionaries any more pleasant.

What’s your weapon of choice for editing OpenFOAM files?

Are you a Notepad++ fan? Are you already into VS Code? Perhaps you’re an Emacs or a Vim wizard? I’m on a slow migration to Vim, but that’s definitely not for everyone.

Let me know your preference – I’m always on the look out for my next text editor & keen to know what I’m missing 🤩

Until next week, stay safe,

Signed Robin K