Search code examples
vimvi

vi pasting messes with formatting


When I opened a vim editor on terminal, I copied the following text to clipboard from another source

    int thisVal = findMin(m);
    // System.out.println(val);
    m.add(val);

But it becomes

                int thisVal = findMin(m);
                // System.out.println(val);
                //                      m.add(val);

Why is this case and how to paste correctly with the formatting? Thank you.


Solution

  • :set paste
    

    should cause indenting to work correctly. As uku points out, you can read more information on paste mode using

    :h paste
    

    you can turn off paste mode with

    :set nopaste