On Sun, 27 Nov 2011, Peng  Yu wrote:

Hi,

I want to customize the behavior of CTRL-W CTRL-F. For example, it is of the pattern #include <header.h>, I will search for C and C++ header file directories. If it is of the pattern import os, I'll search for python library directories for file os.py.

More generally, it a line match for some pattern, I will call an external program (the program could be written as a vim function) to resolve the file to be opened.

:help CTRL-W_f doesn't tell me how to customize it. Could anybody let me know how to do so? Thanks!

See:

:help 'include'      -- 'inc' = how to determine a line might be an 'include'
:help 'includeexpr'  -- 'inex' = how to transform that line into a filename

Generally, filetypes set up some minimal setup, usually enough to handle files in the same directory or a subdir.

E.g. ft=python sets up:

include=s*\(from\|import\)
(which doesn't work... but that's a topic for a different thread)

and:
includeexpr=substitute(v:fname,'\.','/','g')

Obviously there are lots of cases where it could be improved, and it often depends on the way a project is set up. Just wanted to point out the simple setup already present. Most third-party ftplugins do this, too. So, again, you might not have to do the work yourself.

If you do end up trying this on your own, this command is helpful:

:che!                 -- show all files detected as includes
:help :checkpath

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to