Pasting the copied text into vim

Published on Author bloggerfive

Set pastetoggle in .vimrc file to paste the text/code properly which is copied from web page or windows text file.

The Problem

When you copy paste the text/code from web page to vim, it will be something like below.

howwhywhat

      howwhywhat

               howwhywhat

                       howwhywhat

Solution

If you already have .vimrc file in your home directory, set the below variable in .vimrc file. After that close and re-open the file in vim then press i (for INSERT mode) then press <F2> (Functional 2 key) and paste the copied text.

set pastetoggle=<F2>

Notes

  1. <F2> is not mandatory, you can set it to any functional key
  2. If you don’t want to deal with .vimrc file, you can use below commands as well.

         :setpaste (paste mode)

          :nopaste (turn off paste mode)

Comments

comments