stop indentation on current file in vim to keep the indentation from copied text.

I have been looking for this for quite some time. Finally found two easy ways to do it:

:setlocal noautoindent
:setlocal nocindent
:setlocal nosmartindent
:setlocal indentexpr=

Just use the above four commands when the file is already open to stop all the indentation/smart indentation/auto indentation in vim for the current file. If you want to map it then you can use shorthand notations and map it in the .vimrc file.

Example:

:map <F1> :setl noai nocin nosi inde=<CR>

1 thought on “stop indentation on current file in vim to keep the indentation from copied text.”