A couple of weeks ago I started to use Vim and Tmux. One of the problems I’m having, is that when I paste html-markup from the clipboard into Vim the code isn’t properly formatted.
it takes me lot’s of time to format the html properly.
Is anyone familiar with this problem? How can I fix this?
I had this happen when pasting in insert mode. Try adding the following to your vimrc file, using your desired mapping, ‘p’ here. Then paste from normal mode with the mapping.
From @benorenstein, this will indent whole file - by dropping a mark named m (mm), go to top of file (gg) and indent (=) all the way to the bottom (G) and return to mark (`m).
Hi @acandael, I personally use the pbpaste trick that @Paz231listed, and the reformatting tip is also great. I would also add to the list looking into Vim’s paste mode, which you can read up on by running :h paste. This setting instructs Vim to accept pasted content as text rather than trying to process as keystrokes (which causes the duplicated indentation you see in your screenshot).