In article <k3fja8$rm7$
1...@speranza.aioe.org>,
glen herrmannsfeldt <
g...@ugcs.caltech.edu> wrote:
> Paul Anton Letnes <
paul.ant...@nospam.gmail.kthxbai.com> wrote:
> > On 19.09.12 12:27, ??????????????? ?????????????????????????????? wrote:
> >> Its more a vim question then fortran.
> >> When I write a new file, text get indented nicely. But that's not true,
> >> if I paste a code snippet from existing file which is not
> >> indented(obviously that takes the space etc. it has copied as well).
> >> I am thinking of any possibility of applying indention in existing
> >> fortran file.
>
> If by paste, you mean using the cut and paste feature of your
> windowing system, then yes it normally gets indented.
>
> If you :r read from a file, then it doesn't.
>
> I have noticed that mine applies fixed form Fortran indenting
> even to files with the .f90 extension. I haven't tried to find
> out where it does that.
>
> (snip)
> >> In my vim, I have fortran_codecomplete, where I have put:
> >> setlocal tabstop=2
> >> setlocal shiftwidth=2
>
> >> in my vimrc i have fortran specific:
> >> let fortran_more_precise=1
> >> let fortran_free_source=1
>
> > Ask in a vim forum. You're sure to get better answers there.
comp.editors might be a good place -- there seem to be some vim experts
who hang out there.
> > I'm a vim user and I'm not even sure that I understand the question. If
> > you're pasting non-indented text, you're stuck indenting it after
> > pasting, afaik.
>
> If you do cut and paste with a window system, it goes in just
> like it was typed by the user, though a little faster.
>
> There is a mode where, in addition to the six character indent
> for fixed-form it also remembers the extra indent from the
> previous line. If you cut/paste that way you get recursive
> (ever increasing) indentation.
That's the behavior I usually get when I paste into a vim session from
my windowing system (under Linux). That's usually not what I want,
but a ":set paste" first makes it not happen.
If what you want is to reindent the pasted-in text, the "=" command
may be helpful:
If things are set up right [1], "=" reindents in accordance with
whatever rules are in effect [2]: "==" to indent a single line, "gg=G"
to reindent the whole file. ":help =" will tell you a little more.
[1] FSVO "right".
[2] I'm not remembering, and am too lazy to check right now, exactly
how all of this works. If it's not clear from vim's help (which it
well may not be :-)? ), try comp.editors?
--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.