Vim Tips Wiki
(Change to TipImported template + severe manual clean)
(Move categories to tip template)
Line 9: Line 9:
 
|version=5.7
 
|version=5.7
 
|rating=32/11
 
|rating=32/11
  +
|category1=
  +
|category2=
 
}}
 
}}
 
In times past I used a nice editor that had the neat feature of automatically setting pasted text to the proper indent level. Recently I've begun to miss this so I went looking in the help and came up with.
 
In times past I used a nice editor that had the neat feature of automatically setting pasted text to the proper indent level. Recently I've begun to miss this so I went looking in the help and came up with.

Revision as of 01:00, 25 April 2008

Tip 272 Printable Monobook Previous Next

created July 4, 2002 · complexity basic · author RobertKellyIV · version 5.7


In times past I used a nice editor that had the neat feature of automatically setting pasted text to the proper indent level. Recently I've begun to miss this so I went looking in the help and came up with.

=`]

which will format to the end of the pasted text. Perfect to call right after you past something as the cursor ends up at the top of the pasted text, thus the mapping:

:map <c-p> =`]

However I wanted the formatting to automatically be done so it was two simple (once I figured out how!) nnoremap:

" [Feral:185/02@14:27] map c-p to what p was (past with no formatting), map p to p and = to end of pasted text.

nnoremap p p=`]
nnoremap <c-p> p

This simply (as the comment hints at) maps normal mode p to what p did (paste) then = to `] (last character in the previously changed text). While ctrl+p just does what p did. (just in case you find you don't want a bit of text auto formatted.).

References

Comments

See also ]p

Help says, "Like "p", but adjust the indent to the current line." Also note [p