It would be very handy to set a shortcut to script in Kile that replaces given instances of text, like for setting non-breaking spaces (~) around given words within selected text:

(^|~|\s)(I|of|not)\s\s* -> \1\2~
This regexp puts ~ after given words.

I've read through "Scripting" section of the Kile Handbook and there doesn't seem to be any reference to regexps for finding text, and provided examples seem way too tedious for even such simple things as replacing tag contents.

There are, some document.startsWith and similar document.endsWith functions, which require pattern argument, however those seems to apply to whole lines only and the format of pattern argument is unspecified.

Perhaps there's a way to call Edit->Replace command (with needed parameters [like Mode: Regular expression; Selection only]) programmatically (i.e. with kile object).

How do I reproduce regexp behaviour (like the one above) as a Kile script?

  • I'm not sure how good javascript is for regex stuff. I don't know much about it, but I've never heard much about 'javascript's regular expressions' and I wonder if there might not be a good reason for that. To be honest, I don't really see the point of their examples or why they think this is such a powerful feature. OK, I can see it might be useful for auto-completion, but the javascript scripting is hardly required for that. They'd be better off fixing Kile's bugs, although I realise these features are inherited mostly from Kate. Maybe they make sense there. – cfr May 11 '16 at 2:03

Your Answer

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

Browse other questions tagged or ask your own question.