vim - cut / copy paste with indent intact nicely

System administration in Linux / BSD can never do without a text editor, and vim is definitely de-factor editor. vim is not only an text editor, it can be also a IDE (integrated development environment) and it is extremely light in resource. Just to mention a few of its features, syntax highlighting, auto indent, search & replace, copy/cut & paste & others. vim comes with all versions of linux & BSD, check your flavors documentation.

Problem :
copy / cut text from other apps (e.g. gedit, openoffice, kedit, abiword, textmate, notepad, textedit & other text editor) to vim often jumble up the space.

Solution :
before paste / inserting text into vim, run :
:set paste
(notice the colon) and it would reserved the indent

to resume the previous text behavior, run :
:set nopaste

Ciao !!!

1 comment:

Unknown said...

Thanks! this solved my problem!

I'd sure like to know why it has to be so complicated that you have to use commands just to copy paste stuff..?