History Report a problem
Article Edit this page Discussion

Chop long lines

From Vim Tips Wiki

(Redirected from VimTip575)
Jump to: navigation, search

Tip 575 Previous TipNext Tip

Created: October 4, 2003 Complexity: basic Author: mosh Minimum version: 6.0 Karma: 9/3 Imported from: Tip#575


" Some regexp substitutions for your menus from vimrc
:amenu Mo1.Format.ChopLongLines :%s!\(.\{-80,}\)\s!\1<C-v>\r!gc
:amenu Mo1.Format.JoinHypenatedLines :%s,\v\s+(\w+)-\n(\s*)(\S+)\s*, \1\3^M\2,gc
:amenu Mo1.Format.JoinBackSlashLines :%s,\\\n,,gc

[edit] Comments

As far as chopping lines goes, look at man fmt. Note that fmt chops lines to 72 (or is it 75?) by default. You can also set it using fmt flag.

Chop long lines from line 1 to 10

:1,10!fmt

Also, you can do visual block and use fmt! (this is the best part):

  • 'v' to start visual mode in command mode.
  • select a block
  • then type '!fmt<enter>'

Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pushing Daisies
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Astronomy Wiki
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions


Vote for featured Wikia!

Send this article to a friend
"Chop long lines"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation