Registered Member
|
As a former addict of medit text editor's external tools, I think this must be a very useful feature for Kate as well.
However, I couldn't find enough information about it, and therefore it must be difficult for most users to figure out how this feature can be used for different user requirements at the present. For instance, I've found this solution to display document statistics, but apparently much has changed since, and instructions there are not easily adaptable to the current state of affairs: https://www.linuxquestions.org/question ... te-824163/ A couple of up-to-date examples would be very helpful. |
Registered Member
|
Recently I formatted xml with the external tools of Kate. I had xml as one long line, which I wanted to format with indentation. The solution was simple. Activate "Text Filter" plugin, highlight the line with xml, then <ctrl>+\ (or Menu -> Tools -> Filter Through Command) and type "xmllint --format -" as command
BTW, word counting is built into Kate-Part and available in Kate and KWrite. You can also write scripts for Kate ... |
Registered Member
|
@raphaelra Thanks for the tips on Text Filter plugin (which I might also use in some cases as an external tool) and Javascripting (which looks a bit too complicated for me).
I'm also looking for some sort of guidance on how to run shell scripts via Tools > External Tools > Configure... There's only one example there, which I couldn't see working anyway. I tried to copy and use it for my scripts, but it seems I couldn't succeed in using especially the fields Executable and Arguments as well as variables such as %{Document:Path}, %{Document:FileName} and %{Document:Selection:Text} BTW, I couldn't see Word Count in the menus but this not so important for me. For instance, I have a script like this which I use often with my archived html files, and I cannot figure out how to implement it as an external tool in Kate:
|
Registered Member
|
Go to Settings -> Apperance, check "Show word count" and see at Kates's status bar.
It's simple Executable: is the external command, program or script you want to launch and Arguments: are the arguments or options passed to the command. For example, you want to insert word count of the current saved document. Then "wc" is your Executable:, "-w %{Document:FileName}" your Arguments: and "%{Document:Path}" your Working directory:. As Output: (where to write the output of wc) you should choose "Insert at Cursor Position" or "Insert in new Document", if don' want to mess current document.
I would save the above as shell script (don't forget the shebang line), with a litle modification as for example ~/bin/my_script.sh
Make the script file executable. Then you can use it as Executable: and "%{Document:FileName}" as Arguments:. It's like starting this on the command line with "~/bin/my_script.sh my_file.html", where my_file.html is the current file in Kate |
Registered Member
|
@raphaelra Thank you so much!
I've done this setting for word/character count but I forgot it - and didn't look at the status bar! As for the great tips regarding the use of shell scripts as external tools, I'm much better informed now, and will work on this. Then hopefully I can suffice to use Kate only for all my work with text files! |
Registered Member
|
AWESOME !!
I managed to add my python script to Kate. Then, I have also added it to the toolbar. I would like it to be at the end of the toolbar but it seems it's not possible since the toolbar is divided into 3 sections and the <externatools> is in the middle. I really don't understand why there are different sections for the same toolbar. It doesn't make any sense. They could group the actions in categories in order to find them but then I'd like to be able to have them wherever I wanted. I would like also to add the action "Edit > Search in Files" to the toolbar but it seems it's not possible either. BTW: I have had to add ' at the beginning and the end of %{Document:FileName} because there are error messages when there are spaces in the filename. Thank you, thank you, thank ... you for all the information about scripts. It's been very helpful! |
Registered Member
|
Did "Search and Replace" not appears below status bar as button ? I know it's not toolbar but at least a kind of quick access. |
Registered Member
|
Although shortcuts do the same (displaying the dialog box just above the status bar), I have both "Find" (Ctrl+F) and "Replace" (Ctrl+R) in the toolbar: you need to select "Main Toolbar <KatePartView>" for this, and "Main Toolbar <externaltools>" for your scripts. |
Registered Member
|
@raphaelra do you happen to know how to apply a script to selected text only?
For instance, sorting unique (removing any duplicates) or replacing certain characters in selected text?
Last edited by sadi on Wed Apr 22, 2020 11:35 am, edited 1 time in total.
|
Registered Member
|
Did "Search and Replace" not appears below status bar as button ? I know it's not toolbar but at least a kind of quick access.[/quote]
I don't understand. Below the status bar I see nothing. |
Registered Member
|
Not below, above the status bar you should see it when you press Ctrl+F or Ctrl+R. |
Registered Member
|
See below status bar marked with red rectangle near mouse pointer ... Here hidden And here activated
You can pass %{Document:Selection:Text} to a script as Argument: or better as Input: |
Registered Member
|
I've made it at last! Thanks a lot! |
Registered users: bancha, Bing [Bot], Evergrowing, Google [Bot], lockheed, mesutakcan, Sogou [Bot]