On 10/30/06, 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> ......
The following piece of code extracts filename.
nmap <MouseUp> :call OpenFile()<cr>
function! OpenFile()
let line = getline('.')
let col = col('.')
let before = strpart(line, 0, col-1)
let after = strpart(line, col-1)
let left = substitute(before, '.*\[', '', '')
let right = substitute(after, '\].*$', '')
exe ":edit ".left.right
endfunction
untested
Yakov