1

注:与えられた適切な解決策を反映するために、元の質問を書き直しました。

vim(ubuntu 12.04 w / r-plugin)は、以下に示すように、ファイルにコメントが付いたr-pluginがインストールされたRファイルとして.Rまたは.rファイルを認識しません。

# comment
x <- 2
x

コメントがなければ、すべてが正常に機能します。私の〜/ .vim / filetype.vimは次のように読みます:

augroup filetypedetect
  au! BufRead,BufNewFile *.r         setfiletype r
  au! BufRead,BufNewFile *.R         setfiletype r
  au! BufRead,BufNewFile *.Rnw       setf noweb
augroup END
4

1 に答える 1

1

複数のファイルタイプがR拡張子を使用しているようです。私はこれを見つけました$VIMRUNTIME/filetype.vim

" Rexx, Rebol or R
au BufNewFile,BufRead *.r,*.R           call s:FTr()

func! s:FTr()
let max = line("$") > 50 ? 50 : line("$")

for n in range(1, max)
    " Rebol is easy to recognize, check for that first
    if getline(n) =~? '\<REBOL\>'
    setf rebol
    return
    endif
endfor

for n in range(1, max)
    " R has # comments
    if getline(n) =~ '^\s*#'
    setf r
    return
    endif
    " Rexx has /* comments */
    if getline(n) =~ '^\s*/\*'
    setf rexx
    return
    endif
endfor

" Nothing recognized, assume Rexx
setf rexx
endfunc

したがって、VimがRを正しく検出するには、ファイルにコメントを含める必要があります。

RexxまたはRebolファイルを使用したことがない場合は、検出をオーバーライドできます。

au BufNewFile,BufRead *.r,*.R setf r
于 2012-07-30T16:16:04.277 に答える