› Kate polishing 
Thu, 01/21/2010 - 02:09
Phew, I just finished some last-minute backports to the KDE 4.3.5 branch. Lets hope the bug fixes I and pletourn did are as good as they look. Expect a much more stable Kate for 4.3.5 & 4.4! We managed to fix two bugs which are potentially the cause for dozens of bug reports, all seemingly random. Lets see whether our fixes hold up to our hopes!
Other than that: You should look forward to Kate scripting (with JavaScript) in 4.4. It’s dead simple but actually useful. In the utils.js file we ship with Kate there are now the following tools (all operate on the selection or - if none exists - on the whole document):
- sort - simple sorting
- natsort - natural sorting
- uniq - filter duplicates
- trim - remove leading & trailing whitespace
- ltrim - remove leading whitespace
- rtrim - remove trailing whitespace
Do you have more ideas for such simple helper functions?
Comments
Joining lines can simply be Wed, 05/19/2010 - 17:52 — Anonymous (not verified)
Joining lines can simply be done by [ctrl]+[j]. Works with or w/o selection, for just the current line in the latter case. (Using Kate 2.5.10 @ KDE 3.5.10)
just my 2¢
Two functions I use all the Thu, 01/21/2010 - 17:48 — Anonymous (not verified)
Two functions I use all the time are “join lines” and “strip blank lines”. Today I do those with external perl scripts called from the “Filter Text” function. They might be useful as helper functions though. Here are the perl scripts (for reference):
Join Lines:
Strip Blank Lines:
both added now :) Thu, 01/21/2010 - 19:19 — Milian Wolff
both added now :)
Wordcount! Right now, Thu, 01/21/2010 - 12:02 — sebas (not verified)
Wordcount!
Right now, getting wordcount in kate seems like black magic (I have tried, but not succeeded). It would be cool if such a function would be easily available, so I don’t have to go to the console and use ‘wc’ just to know how many words I’m allowed to / have to write still.
see also: Thu, 01/21/2010 - 19:41 — Milian Wolff
see also: https://bugs.kde.org/show_bug.cgi?id=65740
I think I had a nice idea on how to implement that, stay tuned for 4.5 ;-)
Could you link to a page or Thu, 01/21/2010 - 10:33 — dereine (not verified)
Could you link to a page or sth. where there is a description how to use custom user scripts? I cannot find something.
Try that for now: Thu, 01/21/2010 - 14:47 — Milian Wolff
Try that for now: http://dhaumann.blogspot.com/2009/11/scripting-kate.html
Is it possible to assign Thu, 01/21/2010 - 08:20 — niko (not verified)
Is it possible to assign shortcuts to such commands? Or add them to the toolbar? And does it work in KDevelop?
Assigning shortcuts is on the Thu, 01/21/2010 - 14:46 — Milian Wolff
Assigning shortcuts is on the TODO and will hopefully be there for KDE 4.5. And yes, all this is implemented in Katepart, hence works wherever it is used (KDevelop, Quanta, Kile, …).
Hi :-) Could a “duplicate Thu, 01/21/2010 - 02:46 — Anonymous (not verified)
Hi :-)
Could a “duplicate line” feature be implemented with javascript ? I really miss it in Kate. You said “all operate on the selection or - if none exists - on the whole document”, but there could be a lot of useful scripts (like duplicating a line) that need to work on the whole current line. Do you think something can be done for that ?
and thanks to the Kate team !
I tried to add the duplicate Tue, 06/21/2011 - 17:44 — King_DuckZ (not verified)
I tried to add the duplicate line script me too but it doesn’t seem to work. At least, I don’t find it anywhere in kate. I saved it to /home/michele/.kde4/share/apps/katepart/script/duplicate_line.js and it looks like so:
How can I bind that action to ctrl+D?
You need to implement the Thu, 06/23/2011 - 12:07 — Milian Wolff
You need to implement the
action(cmd)function in your script and return an object with thetext,icon,category,interactiveandshortcutproperties set. See alsoutils.jsthat comes with that functionality. Also note that my version (i.e. the one from current git) comes withduplicateLinesDownandduplicateLinesUpscripts - maybe you don’t need to do anything custom anymore?Sorry for the bad formatting, Tue, 06/21/2011 - 19:25 — King_DuckZ (not verified)
Sorry for the bad formatting, I don’t know how to get the tags working. It was just the same function you guys posted here plus the commented header as found in kate’s manual.
Yes, something like that Thu, 01/21/2010 - 04:07 — Milian Wolff
Yes, something like that would be very easy:
That should be it ;-) Didn’t test it, but maybe I’ll add such kind of commands to
utils.js. What else, other than “duplicate line” would you need?above code didn’t work for Fri, 04/16/2010 - 06:30 — Mike Smullin (not verified)
above code didn’t work for me, but this did:
In order for the function to register, looks like you have to insert the name of the function into the comma-separated list in the docblock at the top of the file, as well.
now how to execute commands using hotkeys? (e.g. mapping keys to commands) I’m using Kate version 3.4.2 on KDE 4.4.2.
Thank you :) i don’t see Thu, 01/21/2010 - 10:52 — Anonymous (not verified)
Thank you :) i don’t see something else right now but this looks very useful !
Post new comment