Text Editor than can reflow text

Asked by Bernhard on 2009-03-31

Is there a text editor available that can "reflow text" (i.e. wrap the text into blocks)? I know Emacs can do it with Meta-Q and vim is said to be able to do it. But most editors cannot imho. Are there any others that can? Is there a gedit extension to do it?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Abi ^-^
Solved:
2009-04-01
Last query:
2009-04-01
Last reply:
2009-04-01
Craig Huffstetler (xq) said : #1

You can do this:

Here is what I use to turn on / off word wrap. This code assumes that you don't use the "split words" option (because I don't). I'm sure you can figure out how to include that if you need to.

Create a new External Tool (Tools > External Tools > New) with the commands given below, and add a shortcut key.

x=`gconftool-2 -g /apps/gedit-2/preferences/editor/wrap_mode/wrap_mode`

[ $x = "GTK_WRAP_NONE" ] && gconftool-2 -s -t string /apps/gedit-2/preferences/editor/wrap_mode/wrap_mode GTK_WRAP_WORD || gconftool-2 -s -t string /apps/gedit-2/preferences/editor/wrap_mode/wrap_mode GTK_WRAP_NONE

OR:

You can use the "Edit Shortcuts" plugin to turn word-wrap on or off at your convenience. (Text wrapping is in Gedit ... Edit > Preferences > (First Tab "View") > "Toggle" Enable text wrapping). But to make it easier you can install the plugin "Edit Shortcuts" and enable a shortcut to do what you desire (i.e. add it to the menu so you just have to, for example, hit SUPER + E or META + Q).

I hope this helps.

Plugin referenced: http://empty.23inch.de/pmwiki.php/Main/EditShortcuts

Bernhard (b.a.koenig) said : #2

But is this really like Meta-Q in Emacs? I don't mean turn word wrap on/off, I want to turn a whole paragraph into a block if it looks fuzzy (not like a block). Not just type in wrapped lines but say I have a longer unwrapped paragraph and turn that into a rectangular block.

Best Abi ^-^ (abiyasa-eka) said : #3

Hello, have you try open office writter? ...

Open Oo writter, enable drawing toolbar first, by click menu view - Tools bar - drawing ...

After that, you should see a drawing toolbar in bottom of screen ...

Click text box icon, the icon display it as " T " ....

Drag a text box to the size you want anywhere in the document, and then type or paste your text.

After that you can make it like block by highlight the text, and change the alignment to justify ...

For wrap function, you can do it by right click the text box, and choose wrap option ....

Please accept my apology, if i'm misunderstood with your question

Bernhard (b.a.koenig) said : #4

Yes, you are right. I guess it is possible with open office. But I usually use stuff like gedit or other lightweight editors. And it seems most of them don't have this functionality. :(

Bernhard (b.a.koenig) said : #5

Thanks Abi ^-^, that solved my question.

Craig Huffstetler (xq) said : #6

A couple of things here Bernhard, now that I understand better of what you are looking for.

You are basically looking for the ability to "reformat paragraphs," rather than entire documents for example through justification (so the words are "wrapped into blocks"). Rather it be for coding reasons (for example snippets of code) or anything else. I believe this is possible in gedit.

For your case this is how you would do "META-Q" in gedit for now go and get the Vi(m) Plugin:
Vi(m) (pronounced "Vee Get It") Plugin for gedit:
https://edge.launchpad.net/vigedit/
To quote their homepage it simply " provides Vim key bindings to the gedit editor." It's very useful.

This is how you implement vim's version of "meta q" as a vim keybinding. The V(im) plugin does pick it up. I tested it myself in gedit and vim:
http://markmail.org/message/taaqhpychakcd3ik

(For Coding [side comment]):

If you don't have the gedit plugin package already installed I highly recommend you install it.

On the command-line just:

sudo apt-get install gedit-plugins

This will install a set of plugins for gedit. You can access them in gedit by going to Edit > Preferences > Plugins. Plugins that are helpful, in my experience for coders, are: Bracket Completion, Code comment, Indent Lines, Modelines, and Session Saver, Snippets.

Also, please note that on the homepage for gedit plugins I found a section entitled: "Requested plugins"
Useful plugins that have not been written yet:
Guess what one of them was?
*** Filling-text in current paragraph
* Add a "fill-text in current paragraph" command like the "Meta-Q" command in GNU Emacs. Bug report: gnomebug:149081
I encourage you to comment on this bug report at along with me: http://bugzilla.gnome.org/show_bug.cgi?id=149081

In the meantime, I hope the V(im) keybinding solution helps in gedit. If you have any troubles you can always contact the Vi(m) team.

Sincerely,

Craig

Bernhard (b.a.koenig) said : #7

The new Geany 0.18 has this feature of reflowing text btw.