I am using vim and simply want to disable auto indent when I paste text into my terminal vim session. I have tried numerous solutions including various incantations of below to ~/.vimrc
:
set nopaste
" https://kb.iu.edu/d/afcw
" set noautoindent
" https://vi.stackexchange.com/questions/5310/how-can-i-stop-vim-automatically-inserting-a-tab-in-css-files
" set indentexpr=""
filetype indent off
" set pastetoggle=
set pastetoggle=
" set paste
" se paste
" au FileType html,htmldjango setlocal indentexpr=
" set nosmartindent
" set cindent
" filetype plugin indent on
" set cinkeys-=0#
" set indentkeys-=0#
" autocmd FileType * set cindent "some file types override it
" https://unix.stackexchange.com/questions/106526/stop-vim-from-messing-up-my-indentation-on-comments
set nosmartindent
set cindent
set cinkeys-=0#
set indentkeys-=0#
As you can see bad advice is easily obtained. I am on Ubuntu 18.04 and have not customized anything so its stock vim. I see the vim package has given me
~/.vim/bundle/Vundle.vim/
which I have not modified
vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)
Included patches: 1-1689
Extra patches: 8.0.0056
Modified by [email protected]
Compiled by [email protected]
Huge version without GUI. Features included (+) or not (-):
Here is an example of badness when I paste properly formatted code into vim vim blah.go
import (
"bufio"
"fmt"
"os"
"bytes"
"io"
)
func read_stdin(io_reader io.Reader) (string, error) {
var buffer bytes.Buffer
scanner := bufio.NewScanner( io_reader )
for scanner.Scan() {
buffer.WriteString( scanner.Text() + "\n" )
}
if err := scanner.Err(); err != nil {
return "", err
}
This auto indent issue pervades many filename suffixes so I am not looking for any suffix specific or source code editing language specific addons.
PS this was never an issue until about a year ago