2010-10-21 24 views
0

我想配置Vim的'path''suffixesadd'所以當我使用gfFILE_NAME和PWD爲/some/dir/,它會打開/some/dir/FILE_NAME/File_Name.xml的Vim:GF打開目錄,而不是文件

在vimrc裏,我把:

set suffixesadd=.xml 
set path=.,dir/** 

但是,而不是打開File_Name.xml它打開目錄FILE_NAME

我應該怎麼做來配置VIM,所以它看起來的文件b efore目錄?

PS:IM用gvim在Windows和NERD有積極插件

+3

的常見問題包括: 「程序員通常使用的軟件工具」,像這樣的Vim問題在這裏比SU更容易得到更好的迴應。 – 2010-10-21 12:59:08

回答

1

我不認爲這是可能的gf作爲標準配置,但你總是可以做:

" Mapping to make it easier to use - <C-R><C-W> inserts the Word under 
" the cursor 
nmap gx :call CustomGFOpen("<C-R><C-W>")<CR> 
" The function that does the work 
function! CustomGFOpen(cursor_word) 
    " The directory name (e.g. FILE_NAME) is passed as the parameter 
    let dirname = a:cursor_word 
    " This is a regular expression substitution to convert 
    " FILE_NAME to File_Name 
    let filename = substitute(a:cursor_word, '\(^\|_\)\@<=\([A-Z]\)\([A-Z]\+\)', '\=submatch(2) . tolower(submatch(3))', 'g') 
    " The extension 
    let extension = '.xml' 
    " Join the whole lot together to get FILE_NAME/File_Name.xml 
    let relative_path = dirname . '/' . filename . extension 
    " Open that file 
    exe 'e' relative_path 
endfunction