Reformatting text (or, better, LaTeX) in 80 columns in SciTE

I recently dived into LaTeX, starting with a WYSIWYM editor such as Lix. Now I look at writing tex files in Sci-TE, it already has the syntax, and I adapted the tex.properties file to work on Windows, showing a preview in Go [F5]

One nice thing Lyx encounters, and it’s hard to do with a regular text editor, is to format the text in 80 columns: I can write a paragraph and press Return every time I get closer to the border column, but if after the first draft, I want to add or cut a few words here and there, I end up breaking the layout and having to change new lines.

It would be helpful to have a tool in Sci-TE so that I could select a paragraph of text that I added or deleted a few words and redid it into 80 columns. Something probably didn’t work on the whole document, as it could possibly break the supposed supposed line break.

Perhaps I could easily write a Python plugin for geany, I saw that vim has something similar, but I would like to know if it is also possible in Sci-TE.

+3
source share
4 answers

, , . Google , Lua . Lua, - , , . Lua, SciTE Lua script:

function wrap_text()

    local border = 80
    local t = {}

    local pos = editor.SelectionStart
    local sel = editor:GetSelText()
    if #sel == 0 then return end

    local para = {}
    local function helper(line) table.insert(para, line) return "" end
    helper((sel:gsub("(.-)\r?\n", helper)))

    for k, v in pairs(para) do
        line = ""
        for token in string.gmatch(v, "[^%s]+") do
            if string.len(token .. line) >= border then
                t[#t + 1] = line
                line = token .. " "
            else
                line = line .. token .. " "
            end
        end
        t[#t + 1] = line:gsub("%s$", "")
    end

    editor:ReplaceSel(table.concat(t, "\n"))
    editor:GotoPos(pos)

end

script, SciTE:

command.name.8.*=Wrap Text
command.mode.8.*=subsystem:lua,savebefore:no,groupundo
command.8.*=wrap_text
command.replace.selection.8.*=2

, , .

+4

scite: -, .SciTEUser.properties (Options/Open User Options file):

# Column guide, indicates long lines (https://wiki.archlinux.org/index.php/SciTE)
# this is what they call "margin line" in gedit (at right),
# in scite, "margin" is the area on left for line numbers
edge.mode=1
edge.column=80

... , 80 .

scite, , , .

, , , Edit/Paragraph/Split ( Ctrl-K).

, , scite , , " " geany. , - .

+2

, , ...

:

command.name.0.*=swrap
command.0.*=fold -s $(FileNameExt) > /tmp/scite_temp ; cat /tmp/scite_temp >$(FileNameExt)
command.is.filter.0.*=1

Ciao Pietro

+1

, , -, "break-lines-as-you-type" scite; , , Lua/add-on/extension :

script. SciTE , :

SciteLineBreak.png

Please note that this is almost the same functionality as in geany- it inserts lines when entering text - but not when clicking on the backspace, as well as when copying / pasting.

+1
source

Source: https://habr.com/ru/post/1755752/


All Articles