In my previous articles on IBM i Open Source, I’ve briefly mentioned Microsoft Visual Studio Code. So, in this article, let me show you what it’s all about.
What options do we have for editing our source/applications that reside on our IFS?
- IBMs RDi (Eclipse based)
- Zend Studio (Eclipse based)
- Notepad ++
- 5250 EDTF (Suppose we must put this down as an option!)
The VS Code IDE can be downloaded from https://code.visualstudio.com/
Or Microsoft Visual Studio Code, or VS Code for short, which unlike the first two options in the above list is free!
What is VS Code?
VS Code was developed by Microsoft for Windows in 2015 as a light version of its commercial Visual Studio Product, and it is Open Source Software.
VS Code is a cross-platform, multi-language code editor which can be used for PHP and Node.js development on the IBM i
It can be found on VS Code’s GitHub repository at https://github.com/microsoft/vscode
This IDE is very lean. What do I mean by that? The download includes all you need to edit and maintain your source. If you want anything above and beyond this, you will find it in the extras, or extensions as they are known.
For example, if you want a different theme for your IDE or different keyboard layout as you are used to Notepad ++, there are many, many extensions for you to choose from.
At the time of writing this article there were 13,000 extensions available.
Extensions are accessed from the left-hand toolbar using the icon marked in the figure above.
My Favourite Extensions
Here is a list of my favourite extensions, that greatly help my productivity. Let me know yours.
And additionally, the two mentioned in the next section.
Connect to IBM i
What options do we have to connect to our IBM i?
The first option I will discuss, the one my company uses, is an SSH extension.
The second option is an SFTP extension.
Both the above options work effortlessly with the IFS, allowing us to not only edit, but file maintenance, also moving/creating files/directories etc.
Note: For both these extensions to work, ensure the *SSHD server is running on your box;
As they use the SSH server, all communications are secure.
The first step is to install the SSH FS extension. This can be seen in the illustration below.
Once this extension is installed, we have to configure it to know about our IFS. Follow the steps below to configure SSH for this extension.
This will open the settings in the editor. Place the following JSON in your settings.
The root parameter, here uses the root directory level. Therefore, setting this to “/” will show the whole IFS to the Code editor.
Next, right click on your system under the SSH File Systems and click the Connect as Workspace folder option
And viola! All our IFS folders can now be seen – time to start development!
The SFTP extension works differently from the SSH one. The SFTP extension will use a directory/workspace on your local PC and, upon saving, will automatically transfer any creation/amendments/deletions back to the IFS.
This has the benefit of keeping a local copy on your PC.
As with the SSH extension, we have to configure the settings to use SFTP. This is achieved by using the F1 – command palette function.
Add the following JSON to the settings file.
And away we go! Any time you save a file it will be uploaded to the IFS. Directory /home/andy/formaserve in my example.
The following figure shows this working.
Number one shows the newly created JSON file on my local drive, then when saved, transfers it to the IFS
The bash session in number 3 shows the file on our IFS.
Hopefully in this article I’ve shown how easy it is to use VS Code, I’m sure it is well on the way to be one the best IDEs for Open Source Software, including IBM i development.
If you have any questions, either on this article, or any other open source, use the comments below, or send me a message on twitter @AndyYouens.
I’m looking forward to the next round of the IBM i i-UG user group meetings this year in the UK, on the 7th November 2019.
Hopefully we can all meet up again at these useful user group meetings. Full details can be found on the iUG site here.
Andy Youens is an IBM i consultant/instructor at Milton Keynes, UK-based FormaServe Systems with over 39 years IBM midrange experience.
Leave a Reply