6

我不知道这是否可能,但仍然......问没有坏处。

我正在使用 Vim 编辑新旧的 fortran 文件(.for 和 .f90)。我正在尝试完成,类似于 Visual Studio,因此当我在文件中定义了多个子例程时:

subroutine init ( ibc, nquad, ul, ur, xl, xr )
subroutine output ( f, ibc, indx, nsub, nu, ul, ur, xn )
subroutine phi ( il, x, phii, phiix, xleft, xrite )

我在某个地方给他们打电话:

call init(<cursor is here>

我得到了参数列表,所以我不必记住它们。如果我理解正确,VS 将其称为“智能感知”。

Vim(GVim72)中是否有类似的东西,如果有,如何让它工作?任何提示表示赞赏。


ldigas 编辑:如果我能得到声明行,我也会很满意,也就是说,当我输入:

call init(<cursor is here>

并按完成键,Vim 会在整行中打孔,例如

call init( ibc, nquad, ul, ur, xl, xr )

ldigas edit2:到目前为止撤回了 2 个答案......很有趣。


4

4 回答 4

3

最接近的应该是vim intellisense。不幸的是,它还不支持 Fortran...

于 2009-05-05T03:38:54.623 回答
3

部分答案:

好的,我得到了第一部分:

Vim 的整行补全被调用

<Ctrl-X, Ctrl-L>

(如果它在同一个文件中,顺便说一句,通常不是)

不幸的是,如果子程序声明看起来像

call assemble ( adiag, aleft, arite, f, h, indx, nl, node, nu, nquad, &
nsub, ul, ur, xn, xquad )

(其中“&”是续号)这种方式行不通。有没有人(来吧,脚本 vimers)知道避免这种行为的方法吗?

于 2009-05-05T06:05:28.373 回答
2

快速和肮脏:旺盛的 CTAGS

VIM 非常了解标签。不幸的是,这并不是你想要的那种巧妙的行为:你最终会在窗口之间弹跳,但我认为这很好,因为我没有别的东西。

可能有用的是Photran,但我从未使用过它。但是,由于它是开源且可配置的,您可能会发现有人已经走上了您的道路,例如,似乎有一个VIM 插件。YMMV。

于 2009-05-07T01:28:34.343 回答
2

我认为您可能获得的最接近的是 vim 功能,它的工作原理类似于 intellisense,但让我们使用语法高亮文件作为基础。以我的 .vimrc 文件为例。基本上它为每个列出的类型设置自动完成:如果文件类型被omnisense支持,它使用它,否则它使用语法高亮文件。

syntax on
colorscheme elflord
set tabstop=4
set shiftwidth=4
set nu!
set et!
filetype on
filetype plugin on
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType sql set omnifunc=sqlcomplete#Complete
autocmd FileType c set omnifunc=ccomplete#Complete
if has("autocmd") && exists("+omnifunc")
    autocmd Filetype *
        \   if &omnifunc == "" |
        \       setlocal omnifunc=syntaxcomplete#Complete |
        \   endif
endif 

另一种可能性是查看 vim.org 网站。例如,我在那里找到了以下内容(即使它不完全是您要查找的内容,也只是一个示例)

fortran_codecomplete.vim :完整的 fortran 构造

希望这可以帮助

于 2009-05-05T04:07:07.457 回答