Hello, On 11/1/06, Michael M. Tung <[EMAIL PROTECTED]> wrote:
Yakov Lerner [EMAIL PROTECTED] wrote: > On 10/30/06, Michael M. Tung <[EMAIL PROTECTED]> wrote: > >Hi all: > > > >I am working on a simple plugin and want to make vim > >open a file which appears in text e.g. as > > > > [/tmp/test.txt] > > > >by clicking on it. The path and filename always appears > >in brackets. > > You can do this by mapping <MouseDown> and <MouseUp> > pseudo-keys: > > nmap <MouseDown> ..... > nmap <MouseUp> ...... > > Yakov Thanks for all the helpful replies! I am using the following hack in the ftplugin based on Yakov's suggestion: " define function to open gtd file function! OpenGTDFile()
You can use the "s:' prefix to make this function local to the filetype plugin file.
let line = getline('.') let line = matchstr(line, "\[.*$") let line = substitute(line, "gtd\]", "gtd", "") let line = substitute(line, "\ *\[", "", "") exec ":e ".line endfunction " bind open function to mouse event nmap <2-LeftMouse> :call OpenGTDFile()<CR>
You can use the <buffer> attribute to the map command to make this map local to a specific buffer. If you make the function a script-local function, then you have to use the <SID> prefix for calling the function. - Yegappan
I just discovered that this function propagates to all other files which are opened afterwards (regardless of filetype). Is there any way to keep OpenGTDFile local, i.e. only to the specified filetype (in this case gtd)? I appreciate any help. Best, Mike -- ------------------------------------------------------------------------- Dr. Michael M. Tung Email: [EMAIL PROTECTED] Departamento de Matemática Aplicada [EMAIL PROTECTED] Universidad Politécnica de Valencia Phone: +34 96 3877000 x88287 Inst. de Matemática Multidisciplinar +34 96 38-79777 Edificio 8-G, 2º piso IM: ICQ96423950 Camino de Vera, s/n 46022 Valencia (Spain) ------------------------------------------------------------------------- PGP Public Key http://personales.upv.es/mictun/mtung_pubkey.pgp -------------------------------------------------------------------------