Formatting a Selection


Starting with the cursor in the middle of an un-formatted buffer:

Initial Conditions
<div>
····<p>line·one</p>
······<p>line·two</p>
········<p>line·three</p>
····</div>
NORMAL50%3:1
 

Enter visual mode:

Enter Visual Mode<Esc>
<div>
····<p>line·one</p>
······<p>line·two</p>
········<p>line·three</p>
····</div>
NORMAL50%3:1
 

Move down another row:

Create the Selectionv
<div>
····<p>line·one</p>
······<p>line·two</p>
········<p>line·three</p>
····</div>
VISUAL50%3:1
 

and finally format the selected lines:

Format Selectionj
<div>
····<p>line·one</p>
······<p>line·two</p>
········<p>line·three</p>
····</div>
VISUAL67%4:1
 

Note that Vim formatted only the lines contained within the selection (including lines containing the cursors), and didn't touch the other lines.