Tyranus-Blog
Blog von tyranus.de
2. April 2016

You know the problem you paste something into vi and the result looks like this?

vi: Paste with indent

This is because you are editing a file of a type that vi knows as filetype it uses auto indent for.

You can check the file type vi detected with the following command:

In the case of the screenshot above it was: filetype=javascript  which vi uses auto indent for by default.

So what I de before pasting some text block ist setting the file type to simply text.

And the result looks like this:

vi: Paste without indent

Looks better and takes less time than correcting all those whitespaces and tabs. Right?

You can simply change your file type back afterwards.

1 Comment
2. September 2016 @ 15:14
Antworten

> Looks better and takes less time than correcting all those whitespaces and tabs. Right?
No and yes. It takes less time, but it doesn’t *look better* because telling vim ‚this is plain text‘ makes it stop using syntax highlighting. Sure, you could just use :syntax on, but there’s a better way:

Just use :set paste, then enter insert mode and then paste your stuff.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*

*