Re: Request for a "Rewrap paragraph" function

From: mitchell <>
Date: Thu, 25 Mar 2010 07:05:13 -0700 (PDT)


> I commonly edit HTML files and I want to keep all lines to 80
> characters (where possible). To help with this I would like a function
> in Textadept which did this for the current paragraph at the press of
> a key sequence. I know this has been implemented many times in various
> editors, but I don't know how to do so in Textadept. Are there any
> functions which I could look at which do something similar?

I wrote such a thing for scite-tools way back in the day using Linux's
'fmt' shell command. Note the following was written for SciTE, and is
not compatible with ta. Someone may feel free to port it (add windows
equivalent?) and post on the wiki.

-- from scite-tools scripts/scite/editing.lua

  FILE_IN = '/tmp/scite_input'
  FILE_OUT = '/tmp/scite_output'
  REDIRECT = ' &> '
  FMTP_CMD = 'fmt -c -w 80 '

-- Reformats the selected text or current paragraph using the command
function reformat_paragraph()
  if PLATFORM ~= 'linux' then print('Linux only') return end
  if editor:GetSelText() == '' then select_paragraph() end
  local txt = editor:GetSelText()
  local f, out
  f =, 'w') f:write(txt) f:close()
  f = out = f:read('*all') f:close()
  if txt:sub(-1) ~= '\n' and out:sub(-1) == '\n' then out = out:sub(1,
-2) end
> Regards,
> Russell Dickenson
Received on Thu 25 Mar 2010 - 10:05:13 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:41:07 EST