Sublime Forum

How to use wsl from sublime text?

#1

I have recently switched from linux to windows, I started using using wsl in order not to miss out on linux. I have installed sublime text on windows and I want to use it on wsl, the way is use vscode windows installation on wsl. I have added Sublime Text directory to windows path and could use subl.exe from wsl. But I couldn’t work with Terminus. Also, I am doubtful about the performance of the application because I am probably using Windows tool with wsl file system. See this link.

Please clarify
Thanks

0 Likes

#2

As a Windows application, Sublime has no direct connection to WSL; neither does VSC except that VSC runs a task within WSL that it communicates back and forth with to seem more integrated than it actually is (arguably).

Running the Windows version of Sublime Text and editing Linux files in WSL will work, but since the Linux file system is shared with Windows as a remote file share, it will not be as fast (most likely you will not notice that in regular usage) but more importantly Sublime relies on notifications from the file system to tell it when files are added, deleted or modified, but file shares don’t support that.

As a result, you will need to use the Project > Refresh option to force a rescan; while not the end of the world, depending on what you’re doing it’s easier to miss changes that way.

You can use Terminus with WSL (presuming you mean being able to have WSL terminals from within Sublime), but you’d need to add a custom terminal to your Terminus preferences in order to do that; for example:

        {
            "name": "WSL",
            "cmd": ["wsl"],
            "default": false,
            "enable": true,
            "env": {},
            "platforms": [
                "windows"
            ]
        },

You may want to set this one as "default" instead of the default you currently have set, if you’d like to mostly use this. Terminus uses the default configuration for executing builds (if you use that feature) so setting this as a default saves you from having to manually tell each build to use it as well.

That will launch the default WSL distribution; if you have more than one installed and want to target a specific one, you need to add to the arguments to give it the name, such as the following example

            "cmd": ["wsl", "-d", "Ubuntu"],

You can get around all of the problems mentioned above by running the Linux version of Sublime Text directly within WSL; in that case it’s a native Linux application in which using Terminus will Just Work :tm: , file notifications work, etc.

The downside to this is that WSL’s support for GUI applications is a bit lackluster currently; in particular:

  • Linux windows don’t respond to requests to rearrange themselves, so you can’t snap to the sides of a monitor and so on; you need to size and move them manually
  • By default, the window caption bar won’t have all of the buttons on it you probably want; you can tweak that with the commands outlined below though
  • Linux apps in a window know they’re in a window, but Windows doesn’t tell them where on the screen they are; so menus that are opened too close to the bottom or side of the screen will go off the edge rather than changing their orientation to remain visible.

All that said, I use WSL daily for production work (and on my streams as well) and it works just fine; in my case I use Sublime maximized to make the most of the space in the editing area, so apart from occasionally having to click a little higher on the screen to see a context menu entry, I have had no issues with it.


If you’d like to alter the buttons available in the caption bar of WSL windows, you can use gsettings for that. As the following example shows, the default button arrangement has only the close button, but you can also add others; here the standard minimize and maximize buttons.

 tmartin:PCTERM:~> gsettings get org.gnome.desktop.wm.preferences button-layout
'appmenu:close'
tmartin:PCTERM:~> gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,maximize,close"
tmartin:PCTERM:~> gsettings get org.gnome.desktop.wm.preferences button-layout
':minimize,maximize,close'
0 Likes

#3

Thanks for the response, I have decided to use the wsl version of sublime. But it looks different from native windows applications as you mentioned. Can I make it feel native? Also, it uses adwita theme by default for windows, can I change that?

Also, the above command gives the following error:
(process:994): dconf-WARNING **: 18:23:55.869: failed to commit changes to dconf: Could not connect: No such file or director**y**

UPDATE:
I couldn’t resize the split window in wsl: Here is an image


Also, all the menu fonts look so smaller. Is there any way to improve this.
Please help.
Thanks

0 Likes

#4

Presumably if you change the theme that is installed in your WSL Ubuntu instance (or whatever distro you use) the applications that are executed would use that theme, since as far as they are concerned they’re running under Linux, so the “standard rules” of how applications behave on Linux apply here. That may well be why there is also no way to make them appear as a native Windows window; it would have to somehow make Windows type properties available to Linux applications in a way that they would normally expect.

I’ve not experienced that particular issue (nor have the other couple of people on my team that are also using Linux applications via WSLg). On the face of it, it sounds like dconf is not running, but presumably that is set up out of the box because we’ve not encountered that particular problem.

Anecdotally, I’ve seen people say that installing gnome-settings and then restarting WSL might resolve that particular problem, but I can’t say one way or the other personally.

This works, but the mouse cursor doesn’t take on the <=> shape you might expect when you hover the mouse over the split. I presume that this is related to whatever WSLg is using for its mouse cursor sets, because I have the same problem not only with Sublime but also with some other Linux programs in WSL that also don’t display the split cursor. That could just be me, though.

Sublime has a ui_scale property you can use to make everything bigger, but that will not affect the menu. Possibly that is settable via the GTK theme though.

0 Likes