You are not logged in.

#1 2010-07-07 02:49:03

hbweb500
Member
Registered: 2010-03-13
Posts: 23

Vim and Fortran indentation rules

I am trying to get Vim to nicely indent Fortran code. As you are about to see, I'm not very familiar with the intricacies of .vim config files, or plugins, or anything advanced in Vim whatsoever.

In any case, I think I have a plugin that does what I wants, but it isn't working, located here: http://www.vim.org/scripts/script.php?script_id=2299

In Fortran, one defines a subroutine as such:

subroutine foo(a)
       ...subroutine body...
end subroutine

I would like the code to indent as above. Instead, I get

subroutine foo(a)
...subroutine body...
end subroutine

Where the body isn't indented. The plugin I linked to above looks like it will do what I want, so I put it in ~/.vim/after/indent, as it says in the script. This didn't seem to work, so I put it in /usr/share/vim/vim72/after/indent/. This also did not work.

One interesting thing is that my $VIMRUNTIME and $VIM environment variables are not set. I set $VIMRUNTIME to /usr/share/vim/vim72, but this did nothing.

It should also be noted that the Fortran syntax highlighting support included in Vim 7.2 works just fine.

I feel like my Vim inadequacy is showing here, but I have searched around and can find no reason why this plugin isn't working.

Offline

#2 2010-07-07 03:52:33

hbweb500
Member
Registered: 2010-03-13
Posts: 23

Re: Vim and Fortran indentation rules

Ok, I have it working , but I must first run the vim commands:

:filetype indent on
:set filetype=fortran

I can see why I would need to do the first line, but isn't the file already recognized as a fortran file by vim? The extension ".f90" is listed in filetypes.vim as "fortran". In any case, is there a way to get this to run every time I open a .f90 file?

Offline

#3 2010-07-07 04:13:02

kazuo
Member
From: São Paulo/Brazil
Registered: 2008-03-18
Posts: 413
Website

Re: Vim and Fortran indentation rules

Because you need to put 'filetype on' (or filetype indent on) in your vimrc, without it vim dont do the autodetection of filetype, on buffer load.

:help filetype

EDIT: Vim have one of best manual/help of any program I used, the first most for a vim user is to learn how to use it, and to do this the help help you to learn help =]

:help help

Last edited by kazuo (2010-07-07 04:16:54)

Offline

#4 2010-07-07 04:16:00

hbweb500
Member
Registered: 2010-03-13
Posts: 23

Re: Vim and Fortran indentation rules

Ah, thanks. I had "filetype plugin on", I just needed "filetype on" and "filetype indent on" in there as well.

Offline

Board footer

Powered by FluxBB