2010-10-21 53 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 
相关问题