K
K
Kovalsky2016-09-29 16:18:43
Sublime Text
Kovalsky, 2016-09-29 16:18:43

How to apply code to selected text in Sublime Text?

Given: Sublime Text 3 and XML environment,
Task: place soft hyphens ( ­) in selected pieces of text.
For example, if there is this text:

Твёрдость и коррозионная стойкость
Твёрдость, механическая прочность, устойчивость к ударам и трению 
Жаростойкость, механическая прочность при высоких температурах, коррозионная стойкость

...and if the first and half of the last sentence is selected, then the result of the algorithm should be something like this:
Твё­рдо­сть и кор­ро­зи­он­ная сто­йко­сть
Твёрдость, механическая прочность, устойчивость к ударам и трению 
Жа­ро­сто­йко­сть, ме­ха­ни­чес­кая проч­ность при высоких температурах, коррозионная стойкость

The code for the algorithm itself is in JS. That is, in principle, I can use the node or console of any browser to solve the problem, but since all work with XML takes place in a text editor, the use of third-party tools in relation to the editor would greatly slow down the work. It would be cool to change the selected parts of the text, for example, by pressing some key combination.
Of course, it would be cool if there was a solution specifically for JS, but it really doesn’t matter, I think I can rewrite the existing code, for example, in Python .
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
M-ka, 2016-09-29
@M-ka

This is not a task for zhs .... but purely for the selected editor .... and how it works with autocorrect, understand the one who chose it ....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question