Wikia

Vim Tips Wiki

Changes: Chop long lines

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
 
Line 14: Line 14:
 
<pre>
 
<pre>
 
" Some regexp substitutions for your menus from vimrc
 
" Some regexp substitutions for your menus from vimrc
:amenu Mo1.Format.ChopLongLines :%s!\(.\{-80,}\)\s!\1&lt;C-v&gt;\r!gc
+
: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.JoinHypenatedLines :%s,\v\s+(\w+)-\n(\s*)(\S+)\s*, \1\3^M\2,gc
 
:amenu Mo1.Format.JoinBackSlashLines :%s,\\\n,,gc
 
:amenu Mo1.Format.JoinBackSlashLines :%s,\\\n,,gc
Line 30: Line 30:
 
*'v' to start visual mode in command mode.
 
*'v' to start visual mode in command mode.
 
*select a block
 
*select a block
*then type '!fmt&lt;enter&gt;'
+
*then type '!fmt<enter>'
   
 
----
 
----

Latest revision as of 08:58, September 29, 2008

Tip 575 Printable Monobook Previous Next

created October 4, 2003 · complexity basic · author mosh · version 6.0


" 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

CommentsEdit

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>'

Around Wikia's network

Random Wiki