Why does Kate replace spaces in filename with "%20", thus preventing opening it?
I'm using the 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: a) Using File/Open from Kate's menu, and selecting the file from there. b) Clicking and dragging the file from pcmanfm across to the Kate window. My humble question: Why does the double-click opening method replace spaces with "%20", and how do I fix it? On my main Debian system on the hard drive, Kate (ver 3.8.4) opens a double-clicked file fine. |
Quote:
If you try Code:
ls my notes Code:
ls "my notes" |
I'm not sure teckk is exactly right. %20 is the hexadecimal equivalent to the space character. Spaces in file names have been "ok" to use in both linux and windows (and I think in whatever version of the OS Apple's been using) for quite some time. There are some rules, though.
If your using a terminal emulator (I use KDE, and Konsole alot) it will take spaces for the names of files, but you either have to enclose the entire file name in quotes or you have to use the \ character to make it suppress the special meaning of the next character (the space, in this case, which usually means "here is the next part of the command on this line") and take it as a plain character. So the command to list my file.txt should be typed as Code:
#ls my\ file.txt But here's something I discovered about kate. I often create playlists for my mp3 player using VLC. The standard play list has two lines for every file, the first being a comment, the second being the file name. When I use kate to open the file created by VLC, the file name line always uses %20 for spaces, but the comment line does not. That one reads as you'd expect, with the space character. I usually do a edit -> replace all in kate to change the %20s to the space character. If I recall correctly, kwrite does not do this. So yes, I agree that it's some setting or other in kate that I do not understand either. |
Just a note that the OP, presumably, has also set up a question on the issue on Stack Exchange:
https://unix.stackexchange.com/quest...ing-opening-it |
Quote:
1. start with a letter or number 2. only use letters, numbers, under-scores, hyphens, or dots |
Quote:
https://unix.stackexchange.com/quest...-in-a-filename |
Thanks for your kind responses.
Could I humbly point out that it's not the use of spaces in filenames that is the problem. As I mentioned at the end of my original thread, I have NO PROBLEM double-clicking a filename in pcmanfm* file manager on my main Debian system on the hard drive. Kate happily opens the file, and spaces aren't replaced with %20. (*I think it's an older version than pcmanfm on the live knoppix 7.7.1 on usb stick.) It's when I double-click a file in pcmanfm (ver 1.2.4) ON THE STICK when spaces are replaced by %20 in Kate. I did the following tests (SOLELY on the stick): 1) Using pcmanfm: a) (This is the SAME scenario I've already described in my original thread.) 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. b) While Kate was still open at "a)", I did the following to see what filename was passed to Kate: Code:
$ ps ax | grep kate double-clicked "my notes", KWrite opened a NEW file called "my%20notes". d) I changed the default launch application to Leafpad. When I double-clicked "my notes", Leafpad CORRECTLY opened "my notes". 2) 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 so far: 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. HOWEVER, I still don't know what the cure is. |
I think the answer just given at Stack Exchange is probably on the right track: Pcmanfm is passing the name as a url. There might be something in the Pcmanfm configuration files you can alter, or else there are just four options: use one of the two opening methods that work, add .txt to the file name so that the file type is clear (I'm not sure that would work), or remove the space.
@hydrurga Do you not know the difference between "allowed" and "acceptable"? Have you nothing better to do than to make silly comments about other peoples' posts? |
Quote:
I'm betting this is correct. %20 is the url code for a space, so passing the directory as a URL not as a straight directory would definitely cause this behavior. |
Solved!
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 very much for the help that you've all given. |
Nice one!
Here is a list of the parameter options recommended in the freedesktop.org standard (half-way down the page). https://standards.freedesktop.org/de...ec-latest.html You will notice that %U allows multiple files to be passed to the target application (e.g. you could highlight several files and then open them all in Kate). So, a better bet might be to replace the %U by %F. Try this out and let us know how it goes. |
All times are GMT -5. The time now is 06:18 AM. |