1 |
What is the solution to begin able to paste code I find on the web |
2 |
into a file in vim and being able to keep the indentation from |
3 |
changing? |
4 |
|
5 |
For instance, here's the first few lines of code from a web page: |
6 |
|
7 |
#define ARRAYSIZE(x) (sizeof(x)/sizeof(*(x))) |
8 |
|
9 |
int main(void) |
10 |
{ |
11 |
const char filename[] = "file.csv"; |
12 |
/* |
13 |
* Open the file. |
14 |
*/ |
15 |
|
16 |
The indentation on the code from const down is consistently 3 spaces: |
17 |
|
18 |
|
19 |
Pasted into vi: |
20 |
|
21 |
#define ARRAYSIZE(x) (sizeof(x)/sizeof(*(x))) |
22 |
|
23 |
int main(void) |
24 |
{ |
25 |
const char filename[] = "file.csv"; |
26 |
/* |
27 |
* Open the file. |
28 |
*/ |
29 |
|
30 |
In this case const is correct, but the next line is 6 spaces, then 9 |
31 |
spaces, then 12 spaces. |
32 |
|
33 |
If it matters, I'm using KDE using Konsole, but I've seen this in |
34 |
other WMs. I looked at the Tab settings in my Konsole profile but |
35 |
nothing seems to matter. |
36 |
|
37 |
Thanks, |
38 |
Mark |