The WinSCP is a great and improved FTP client for Windows that allows you to access remote Linux servers via SSH, FTP, and SFTP. However, the default file editor isn’t ideal for most of us that work with code.
With the wrong/default editor, you can save the remote Linux file in the wrong format (the Windows format) and sometimes it can break your website or web application.
So, in this tutorial, we’ll learn how to set up the WinSCP to work together with your safe and preferred code editor – let’s use Notepad++ and Visual Studio Code as examples in this tutorial, but you can use any other you wish.
Before starting the setup, firstly get the path of the executable file of your editor.
In my case, I found the VS Code executable in the following path:
C:\Users\YOUR-USER\AppData\Local\Programs\Microsoft VS Code\Code.exe
Remember to replace the YOUR-USER with your real Windows username.
The Notepad++ executable I found on the following path:
IMPORTANT: If you have any of these editors installed in a different path, find it before continuing.
Now, that you already know the path of your preferred editor, follow the steps below:
- Download WinSCP and install it;
- After the installation, access the “Preferences” screen (you can do that by clicking the gear icon on the top of the main screen or you can use the “New Session > Tools > Preferences” path) and after that click on the “Editors” option;
- On the editor preference screen, click on the “Add” button and choose the “External editor” option;
- Now click on the “browser” button and on the open dialog go to (or just copy and paste on the “file name” input) the executable’s path of your preferred editor, then click on the “open” button of the open dialog;
- Your editor should now be available in the WinSCP editor list, but it is still not preferred. To do this, click once on your editor name in the list to mark it, and click the “Up” button several times until the editor is at the top of the list;
- Still, on the preferences screen, click on the “Panels” option and check the “Show hidden files” – on Linux the hidden files start with a dot, like the “.htaccess” file, for example, so is extremely important to check this option to be able to see these files on the remote servers;
- Now, still, on the preferences screen, go to the “Environment > Interface” section and choose the “Commander” option as interface style (this will enable 2 panels: local files and remote files), then click on the “OK” button to save all changes;
- To test if everything is working correctly (you need access to a remote Linux server for this of course), go to “New Session > New Site” and choose the type of protocol you want (FTP, SFTP, etc.) or simply enter the name or Server IP and port number. For example, Hostname: servername.com – Port number: 21 (usually used by the FTP protocol) or 22 (usually used by the SFTP and SSH protocols) or any other that your server use, also enter your username and password, then click on the “Save” button;
- Now, in the left panel, your server will appear in the list, so just double-click to open it. After accessing, right-click on the file you want to edit and choose “Edit” or just double-click on it, and the file will be opened with your preferred editor ready to be edited.
The editors used as examples in this tutorial, Notepad++ and Visual Studio Code, auto-detect the Unix files, and apply the correct formatting, this ensures that you’ll save the remote files in the correct format.
IMPORTANT: When accessing the server for the first time via WinSCP, you will be asked to confirm an authentication cryptographic key.
To complement this tutorial and let your workflow even better, check this another tutorial: