Use Windows VScode to edit Linux files.

VScode is one of the best code editors with lots of add-on packages. Although you can install VScode in linux and use X windows to edit in linux, most people run VScode in Windows and would like to edit Linux files from Windows within VScode. There is a simple way to do this using the Mobax terminal https://mobaxterm.mobatek.net/ .

First download ad install Mobaxterm and make sure you can login to linux using ssh with Mobax terminal.

Once logged in to ssh terminal on the left it will show a directory of your files in home directory. Right click on any file and click Open With->Select Visual Studio Code (make sure you had already installed VScode in windows).

The linux file will open in VScode editor. Now if you make any change and save the file in VScode it will pop-up a Mobax prompt asking if you would like to save the file to remote server. Click yes and the changed file is saved in linux. So it feels like you are working directly in Linux.

You can even run Python code in VScode in the linux file. Just right-click on the File in VScode and click Open in Terminal. It will open a terminal session in VScode and the file will be in a directory and you can run it with python in windows. So now you can use python editor as well:

PS C:\Users\userid\Documents\MobaXterm\slash\RemoteFiles\135498_12_1> python mypythonscript.py

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.