commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
This is assuming that you're editing some file that has not been wrapped at 80 columns, and you want it to be wrapped. While in Vim, enter ex mode, and set the textwidth to 80 columns:
to get to the top of the file, and:
to wrap every line from the top to the bottom of the file at 80 characters.
Of course, this will lose any indentation blocks you've setup if typing up some source code, or doing type setting. You can make modifications to this command as needed, as 'gq' is the formatting command you want, then you could send the formatting to a specific line in the file, rather than to the end of the file.
Will apply the format from your current cursor location to the 49th row. And so on.
There are 2 alternatives - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.