Vi insertion riots with formatting

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

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

But he is becoming

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

Why is this the case and how to correctly insert into the formatting? Thank.

+5
source share
3 answers
:set paste

should cause the indentation to work correctly. As uku points out, you can read more about insert mode with

:h paste

you can disable paste mode with

:set nopaste
+10
source

Using

:set paste

or

:set noai

Noai (no auto-indent) can be disabled again with :set ai

+1
source

:

vi ~/.vimrc

,

:set paste #will enable the paste mode as answered above
:set nu #this will show the line numbers for editor

:

autoindent(ai)
autowrite(aw)
exrc(ex)
errorbells
flash
ignorecase(ic)
lisp
list
magic
modelines
number(nu)
showmatch(sm)
showmode(smd)
wrapscan(ws)

, - .

0

All Articles