12

I am using vim 7.2 from putty terminal.
Even if I run set noai it seems vim still trying to indent code. I am copying my code from Notepad++ to vim. following is from Notepad++

alt text

and following what I got in vim:
alt text

I don't have any tab in my file.
As a workaround I am opening old vi run set noai paste save and open in vim again. Any suggestion how to correct this behavior ?

5
  • why negative vote? Commented Sep 1, 2010 at 13:59
  • Probably because your question is not strictly Unix related. VIM runs just about any platform known to mankind. Commented Sep 1, 2010 at 14:24
  • @wzzrd: I thought its something to do with putty and unix terminal. Commented Sep 1, 2010 at 16:46
  • 1
    @wzzrd, really? I mean, there are a lot of unix related tools that run on non-unix systems as well. Including Windows versions of sed/grep for example ... And besides, what would be a better stackexchange site for vim questions? Commented Sep 1, 2010 at 17:30
  • 1
    Guys, guys, guys: I did not downvote this question. I am merely guessing what might be the reason for the downvote. As a matter of fact: I just upvoted it :) Commented Sep 1, 2010 at 18:56

2 Answers 2

9

This has nothing to do with the noai option. What you are experiencing, is a little trouble copy-pasting a load of text with existing indents to vim.

What I usually do (I have this 'problem' a lot), is bind F4 to invpaste and then, before I paste stuff into vim, hit that key. It makes the problem go away.

nnoremap <F4> :set invpaste paste?<CR> 

Read more about this using

:help paste 

inside vim

1
  • wow that worked. I will check :help paste :-). Thanks alot. Commented Sep 1, 2010 at 13:36
3

:set paste prevents the problem

:set nopaste to undo the above

:set pastetoggle=<F2> sets paste toggle key to F2

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.