Why does Kate replace spaces in filename with “%20”, thus preventing opening it

kate

I'm using the Kate editor ver 16.04.2 on live knoppix 7.7.1 on a usb stick.

When I double-click on a normal text file in pcmanfm, Kate opens but it
replaces the spaces in the filename with %20, and a message says "New", which
I presume means "new file". The contents of the file I double-clicked on do not
appear in Kate, but the text window is empty.

Say the true filename is my notes, then Kate changes it to my%20notes.

If I open Kate separately, then opening the file in the following ways DOES
work:

  • Using File/Open from Kate's menu, and selecting the file from there.
  • Clicking and dragging the file from pcmanfm across to the Kate window.

On my main Debian system on the hard drive, Kate opens a double-clicked file
fine. Why does the double-click opening method replace spaces with %20, and how do I fix it?


Edit:

I did the following tests (on the live knoppix 7.7.1 on usb stick). They may
help in identifying what the remedy is for my problem.

Using pcmanfm

(This is the same scenario I've already described in my original question.)

Kate was already the default application that's launched when a text file is
double-clicked. I double-clicked the file my notes in pcmanfm, but Kate
opened a NEW file called my%20notes, with nothing in it.

While Kate was still open, I did the following to see what filename was passed to Kate:

$ ps ax | grep kate
4893 tty5     Sl     0:01 kate -b file:///home/knoppix/my%20notes

I changed the default launch application from Kate to KWrite. When I double-clicked my notes, KWrite opened a NEW file called my%20notes.

I changed the default launch application to Leafpad. When I double-clicked
my notes, Leafpad CORRECTLY opened my notes.

Using nautilus file manager:

I set the default launch application to Kate. When I double-clicked my notes,
Kate CORRECTLY opened my notes (ie no %20 used).

Conclusions

It seems to be ONLY pcmanfm (not other file managers, such as nautilus) that
causes %20 to be used in Kate. Also it seems to be KDE launch applications
(Kate and KWrite) in which the %20 problem occurs — but only via pcmanfm. I
don't think pcmanfm itself is a KDE application.

Best Answer

I've found the cure!

I'm using the LXDE desktop environment, and did the following to fix the problem.

Select the KMenu icon at the left end of the Desktop Panel at the bottom of the screen. Select Accessories/MainMenu. When the MainMenu application appears, click on Accessories in the left box, then click on Kate in the middle box, then click on Properties at the right.

In the "Command" box, replace "kate -b %U" with "kate -b".

When I now double-click a text file in pcmanfm, Kate correctly opens the file, ie spaces aren't replaced with %20.

I don't have much knowlegde of the percent parameters (like %U), but I've a feeling that %U might mean "Treat the argument supplied to Kate as a URL" (not as a normal file).

Thanks immensely sourcejedi and Michael Mrozek for putting me on the path to the solution.

Related Question