When using Vim in a dummy terminal, pasting text into Vim can be result in indentations which get progressively longer as the screen fills up. This vexed me for quite some time until I discovered that there is a simple fix for it. When you want to paste into Vim, just type following into Vim’s command-line.
Now pasting will work as expected.
When you’re done pasting, be sure to turn pasting off by issuing the following command. Otherwise, you’ll notice strange behavior when editing – such as autoindent not working.
Vim has a very nice feature that lets you pipe text from a Vim buffer into a filter (i.e., command). Lets say your Vim buffer is filled with unformatted JSON text – but nothing more. Just issue the following command-line in Vim’s command mode.
The buffer will now be filled with nicely formatted JSON.
On the other hand, if only a portion of the Vim buffer contains JSON, use CTRL-V to select the JSON, then, while still in normal mode, type !ppjson. In Vim’s command line, you will see:
Hit ENTER and the unformatted JSON will be replaced by formatted JSON.