As mentioned above, nedit can do this (Fill, Ctrl+J), but nedit uses Motif and Motif looks like crap on a modern Linux desktop -- no aa or font smoothing or anything. Emacs can also do it, but then again Emacs can do anything. jEdit can do it, but I was never a fan of jEdit (or any Java software for that matter).
If you're learning vi(m), then there's certainly a way to write a macro in there that will do this. The manual way is
:%!fmt -w 62, but I'm fairly certain you can ask vim how wide it's terminal is in a macro.
I cracked open gedit (the default Gnome editor -- if you have a vanilla Ubuntu install, it'll be called "Text Editor", not gedit or anything). Here's how you can set up something that should be close enough, assuming you don't mind playing with the parameters somewhat.
gedit contains a plugin called "External Tools" -- you have to enable this plugin in the preferences pane first. After you enable External Tools, then either go to Configure, or do Tools->External Tools...
Anyway, create a new external tool called whatever, and then paste this into the external Command(s): window. You'll have to mess with the M and B things to get it right, and if you have the side pane open, it'll throw off the calculations. But it does work, and does roughly what you want. Oh yeah, for the new tool, set Input to "Current Document", and output to "Replace Current Document".
#!/bin/sh
M=9
B=13
CURRENT_WINDOW_ID=`xprop -root|awk '/_NET_ACTIVE_WINDOW/ {print $5; exit;}'`
CURRENT_WINDOW_X=`xwininfo -id $CURRENT_WINDOW_ID | awk '/Width: / {print $2}'`
# bash can't do floating point math. it is teh suck.
CHARACTERS=`echo "scale=4; ($CURRENT_WINDOW_X-$B)/$M" | bc | awk -F"." '{print $1}'`
echo Running fmt -u -w $CHARACTERS > /dev/stderr
fmt -u -w $CHARACTERS
Note that this just runs it through fmt -- don't use this for code or anything. Also, if you change your font size constantly, that's going to mess it up too. I'm assuming you're using a fixed-width font here. The settings there are ones I figured out for my own setup. You'll have to fine tune them for your font and resolution and so forth.
If fmt doesn't behave well enough for you, you can replace the call to fmt with a convoluted perl one-liner that loads Text::Wrap and get finer control over how things are wrapped.
It would probably be very possible to formalize this into a Fill plugin for gedit, as the main weakness of this one is the inability to get the width of the editing buffer from the External Tools plugin (it does pass some variables in the environment to the script, but they mostly deal with the document's name). The only choice we have is to ask the X server what the active window is, and estimate the character width of the buffer from the window's physical size.
I know I really am a noob with Linux at the moment, but that's something I'd really like to change. I am something of a 'power user' with Windows, but I'd like to get to a stage where I don't need to depend on Windows just to be good at using my computer. So I'm trying to get there... slowly... but I'll get there eventually
Welcome to Unix. I've been doing this for 15 years or so (I migrated from Windows 3.1), and I'm still learning new stuff. If you have the mindset of a programmer, and don't mind taking the opportunity to do things yourself, you'll get on fine. Many, many Unix programs aren't powerful because of how many features they have built in, but because they hook into the environment and allow you to do stuff like the above fairly easily. Despite the teeth gnashing and hand waving about making Linux "easy", Unix is still fundamentally an environment built by programmers for programmers.
Learning how to program bash scripts, and to a greater extent, learning some perl, will help you in doing things that would be inconceivable on Windows with the same level of effort.
This post is getting a bit long, but as an example to illustrate the point, I wrote a twitter client last week to fetch the top 5 things and put them into files that
conky can read so it shows up on my desktop:
#!/usr/bin/perl
use strict;
use Net::Twitter;
use Text::Wrap;
use HTML::Entities;
use File::Slurp;
$Text::Wrap::columns = 33;
my $filebase = "/home/iwarford/.conktwit/ct.";
my $account = Net::Twitter->new(username=>"iwarford", password=>"doilooklikeanidiot?" );
my $twits = $account->friends_timeline( { count => 5 } );
for (my $y = 0 ; $y < scalar @{$twits} ; $y++) {
write_file($filebase."$y.n.txt", $twits->[$y]->{user}->{screen_name} . "\n");
my @lines = split("\n", fill("","",decode_entities($twits->[$y]->{text})));
push @lines, ("") x (5 - scalar @lines);
for (my $f = 0 ; $f < scalar @lines ; $f++) {
write_file($filebase."$y.$f.txt", $lines[$f] . "\n");
}
}
(The reason it splits every line into it's own file has to do with how Conky reads stuff. That's the best way to do it that I'm aware of.) Anyway, after a conkyrc to read the above, it comes out looking like
this on my desktop.
That took like an hour or two to do -- to do that on Windows, you would basically have to hope that someone else had already written a plugin for a widget thing that you could use. It wouldn't be nearly as easy to get what you wanted. It would certainly be possible, but unless someone had already done it, it would be alot more work.