I have recently changed Windows OS for Ubuntu. As developer I really loved WinSCP on Windows and I just can't find any other suitable program on Linux.

However, everything works fine with WinSCP running on Wine except I am not able to simply double click on the file and open it in Sublime Text Editor.

in Preferences -> Editors I have tried to set /usr/bin/subl and /opt/sublime_text/sublime_text as default editors but none of those two works for me.

When I open a file on remote server Sublime is opened but it is empty with no content inside. Or if doing right click and choosing "Open" from menu I get "There is no Windows program configured to open this type of file".

Does anyone know how to set WinSCP to open file with local editor?

  • I found out that for most file types right click and Open works just fine. For example .html and .xml files can be opened with local editor (Sublime) while opening the .php files throws out an error There is no Windows program configured to open this type of file.
    – PerS
    May 23, 2016 at 11:00
  • 3
    There are plenty of native Linux solutions besides running WinSCP in Wine. Take a look at SSHFS, for example. This question covers several other solutions, as well.
    – MattDMo
    May 23, 2016 at 14:18
  • I am aware of native Linux solutions but so far I couldn't find one that would work in a way WinSCP does. I like to have directory tree left of the main panel. Files should be opened on double click with Sublime and auto uploaded back when I save them. So far FileZilla is the closest but it does not support automatic upload of a file after it was saved in a local editor. And is super annoying to click OK transfer the files, for every save you make. Therefore I hope there is a solution for opening PHP files with Sublime or that there is some native app I have missed that can cover my needs :)
    – PerS
    May 23, 2016 at 17:49
  • By default Wine exposes the Linux root file system as drive Z:. Have you tried to set the editor to Z:/usr/bin/subl? Though in general I agree with @MattDMo: there are plenty of file managers like that for Linux, some of that have SSH/SFPT support through gvfs and then there's SSHFS. May 28, 2016 at 9:43
  • yes, I have tried that.. The problem with native editors is that I can not get a workflow I am used from winSCP. My requirements are: on double click open file in editor. On CTRL+S files should be auto uploaded back to server. Not necessary but I would like to have the Explorer style layout with directory tree and not the commander style layout. If anyone would know of such client build for Linux I would be happy to use it!
    – PerS
    May 30, 2016 at 11:50

1 Answer 1


I had exactly the same problem (Ubuntu + Wine + WinSCP + Sublime) and Sublime was giving me blank pages once I've tried to edit with it. Googling gave me nothing so I've made my own solution for that (tested on Ubuntu 14.04 Trusty)

Here is my solution and research.


Solution tested and works with Ubuntu 14.04 Trusty + Sublime 3 + Wine-1.6.2. I think it will also work for Debian (haven't tested).

I've split solution into 2 scripts to have two universal tools instead of one specific.

The solution is add a script to fix the path before it's get's to Sublime:

  1. First script wine2unix-path will transform Wine "windows path" into real file system path and fix it's format (quotes and double backslashes \\)
  2. Second script sublime.exe will use fixed real file path from wine2unix-path and will pass it into Sublime.

I've named first script "sublime.exe" because otherwise Wine refuses to see it in "Editors" settings, when I update editor path.

Steps to do:

  1. Create /usr/local/bin/wine2unix-path
  2. Create /usr/local/bin/sublime.exe
  3. Update editor path in WinScp

Step 1. wine2unix-path

Example usage: wine2unix-path c:\\Program files\\WinScp\\Log.txt returns /home/YOUR_CURRENT_LINUX_USER/.wine/drive_c/Program files/WinScp/Log.txt.

  1. Create file sudo touch /usr/local/bin/wine2unix-path
  2. Make executable sudo chmod +x /usr/local/bin/wine2unix-path

Put following script into it:


# Trim quotes
FILE=$(echo "$@" | sed -e "s#\(^['\"]*\)\|\(['\"]*$\)##g")
USER_NAME=$(id -u -n)
DRIVE_LETTER="`echo $FILE | sed -e "s/^\([a-Z]\):.*/\1/" | awk '{print tolower($0)}'`"

echo "$FILE" | sed \
    -e 's#\\#\/#g' \
    -e "s#^[a-Z]:#/home/${USER_NAME}/.wine/drive\_${DRIVE_LETTER}#"

exit 0

What this script do:

  1. FILE - Get file path and trim " and ' quotes if there is any
  2. USER_NAME - Get current user name /home/USER
  3. DRIVE_LETTER - Get drive letter from file path (first character). It may be different C:\ refers to .wine/drive_c, D:\ refers to .wine/drive_d etc.
  4. Update file path
    1. Replace root path C:\ with full path to wine folder. C:\ becomes /home/USER/.wine/drive_c
    2. Replaces \\ (escaped backslashes in a windows way) with \, otherwise C:\\users\\files become C:usersfiles when it passed to sublime.
  5. Output result file path (real file path)

Step 2. sublime.exe

  1. Create file sudo touch /usr/local/bin/sublime.exe
  2. Make executable sudo chmod +x /usr/local/bin/sublime.exe
  3. Put there provided below
  4. Change /opt/sublime_text/sublime_text path in script below (last line) with yours sublime path.

My Sublime version 3103 is located at /opt/sublime_text/sublime_text


# Wrapper script to open sublime from Wine
# File path passed as a first argument should be "quoted" and "escaped"
# other wise spaces will split path into two
# For example: sublime.exe "c:\\Program files\\WinScp\\Log.txt"

# wine2unix-path is a help script to convert "Wine windows paths"
# to real paths in linux so sublime can access it
# For for example:
#     ./sublime.exe "c:\\Program files\\WinScp\\Log.txt"
# Will result:
#     /home/YOUR_CURRENT_LINUX_USER/.wine/drive_c/Program files/WinScp/Log.txt

unixpath="`wine2unix-path $1`"

/opt/sublime_text/sublime_text "$unixpath"

What this script do:

  1. Converts Wine file path to real file path.
  2. Passes this path quoted (to avoid split path by spaces) to sublime.

Step 3. Update editor path in WinScp

  1. Open WinScp
  2. Go to Options > Preferences > Editors
  3. If you already have Sublime in editors:
    1. Select line with sublime
    2. Click Edit button
    3. Set following path for "External editor" Z:\usr\local\bin\sublime.exe \"!.!\"
    4. Click Ok. Done
  4. If you don't have Sublime in editors:
    1. Click Add (to add sublime editor and assign it to file types).
    2. Set following path for "External editor" Z:\usr\local\bin\sublime.exe \"!.!\"
    3. Set you list of file types you want to edit with it in "Use this editor for following files". I use it for PHP files and some configs *.ini; *.txt; *.php; *.tpl or *.* for all file types
  5. Make sure Sublime line is on top of the list in Editor preferences. It will make priority for file types you selected for Sublime.

Picture: Sublime settings in WinScp

Research of the problem

The problem appear in file path that Wine passes to Sublime:

  • Path is not quoted with " or ' when it passed to sublime
  • Path backslashes are doubleescaped \\

An example:

  1. File to edit /server/user/www/my project/some other file.php
  2. Wine calls sublime Z:\opt\sublime_text\sublime_text /home/CURRENT_USER/.wine/drive_c/Program files/WinScp/server/user/www/my project/some file.php (path not quoted or escaped)
  3. System run it as /opt/sublime_text/sublime_text /home/CURRENT_USER/.wine/drive_c/Program files/WinScp/server/user/www/my project/some file.php.
  4. So command being interpretative as:
    1. Command /opt/sublime_text/sublime_text
    2. Argument /home/CURRENT_USER/.wine/drive_c/Program
    3. Argument files/WinScp/server/user/www/my
    4. Argument project/some
    5. Argument file.php

As the result path being split by spaces because of the lack quotes. As I found later there is also problem with double escapes \\ in a path

  • /opt/sublime_text/sublime_text "$(winepath "$1")" works for me too, without needing the wine2unix-path file
    – unloco
    Dec 4, 2020 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.