On Thu, Jan 27, 2011 at 11:07 AM, Mark Knecht <markkne...@gmail.com> wrote: > What is the solution to begin able to paste code I find on the web > into a file in vim and being able to keep the indentation from > changing? > > For instance, here's the first few lines of code from a web page: > > #define ARRAYSIZE(x) (sizeof(x)/sizeof(*(x))) > > int main(void) > { > const char filename[] = "file.csv"; > /* > * Open the file. > */ > > The indentation on the code from const down is consistently 3 spaces: > > > Pasted into vi: > > #define ARRAYSIZE(x) (sizeof(x)/sizeof(*(x))) > > int main(void) > { > const char filename[] = "file.csv"; > /* > * Open the file. > */ > > In this case const is correct, but the next line is 6 spaces, then 9 > spaces, then 12 spaces. > > If it matters, I'm using KDE using Konsole, but I've seen this in > other WMs. I looked at the Tab settings in my Konsole profile but > nothing seems to matter. > > Thanks, > Mark >
I solved it by creating a .vimrc file and putting set pastetoggle=<F2> in it. Now I hit F2, vim says (paste), I do the paste and it works nicely. - Mark