Re: Making C-] do something different
* Chuck Mason [2006.12.13 17:15]: In :help it follows links (Maybe there's a helptags file?). Bingo. :h helptags [...] For instance I have a line that looks like: ... sometext somenumber1 someothertext2 And if the user presses C-] anywhere on the line I would like to take somenumber1 and do something with it (follow it by replacing the current buffer with another file referenced by the number). If the line doesn't start with ... Then ignore the keypress. I think I can handle all that but I want to know if its possible to: One way: Define a function which will determine if your line matches and act accordingly: function! Foo() if getline(.) =~ ^\\.\\.\\. extract somenumber1 and do something with it else do nothing endif endfunction And use autocommands to determine whether your function should be called or not depending on which buffer you're in: autocmd BufEnter *.tmp map C-] :call Foo()CR autocmd BufLeave *.tmp unmap C-] All that is left is extracting somenumber1. -- JR
Re: Making C-] do something different
Jean-Rene David wrote: * Chuck Mason [2006.12.13 17:15]: In :help it follows links (Maybe there's a helptags file?). Bingo. :h helptags [...] For instance I have a line that looks like: ... sometext somenumber1 someothertext2 And if the user presses C-] anywhere on the line I would like to take somenumber1 and do something with it (follow it by replacing the current buffer with another file referenced by the number). If the line doesn't start with ... Then ignore the keypress. I think I can handle all that but I want to know if its possible to: One way: Define a function which will determine if your line matches and act accordingly: function! Foo() if getline(.) =~ ^\\.\\.\\. extract somenumber1 and do something with it else do nothing endif endfunction And use autocommands to determine whether your function should be called or not depending on which buffer you're in: autocmd BufEnter *.tmp map C-] :call Foo()CR autocmd BufLeave *.tmp unmap C-] All that is left is extracting somenumber1. or rather autocmd BufRead,BufNewFile *.tmp \ map buffer C-] :call Foo()CR see :help :map-buffer Best regards, Tony.
Re: Making C-] do something different
Hi, On 12/13/06, Chuck Mason [EMAIL PROTECTED] wrote: In source code, C-] follows a tags file. In :help it follows links (Maybe there's a helptags file?). But I've created a new temp buffer from some vim code and I want C-] to do something different for only this buffer. For instance I have a line that looks like: ... sometext somenumber1 someothertext2 And if the user presses C-] anywhere on the line I would like to take somenumber1 and do something with it (follow it by replacing the current buffer with another file referenced by the number). If the line doesn't start with ... Then ignore the keypress. I think I can handle all that but I want to know if its possible to: either set up a handler for C-] or must I just :map it? If I must :map it, I can :map so it only affects the current buffer? :bmap? Any help would surely help! You can refer to the following tutorial on creating keymaps in Vim: http://www.geocities.com/yegappan/vim_keymap.html - Yegappan
Making C-] do something different
In source code, C-] follows a tags file. In :help it follows links (Maybe there's a helptags file?). But I've created a new temp buffer from some vim code and I want C-] to do something different for only this buffer. For instance I have a line that looks like: ... sometext somenumber1 someothertext2 And if the user presses C-] anywhere on the line I would like to take somenumber1 and do something with it (follow it by replacing the current buffer with another file referenced by the number). If the line doesn't start with ... Then ignore the keypress. I think I can handle all that but I want to know if its possible to: either set up a handler for C-] or must I just :map it? If I must :map it, I can :map so it only affects the current buffer? :bmap? Any help would surely help! Chuck
Re: Making C-] do something different
Chuck Mason wrote: In source code, C-] follows a tags file. In :help it follows links (Maybe there's a helptags file?). But I've created a new temp buffer from some vim code and I want C-] to do something different for only this buffer. For instance I have a line that looks like: ... sometext somenumber1 someothertext2 And if the user presses C-] anywhere on the line I would like to take somenumber1 and do something with it (follow it by replacing the current buffer with another file referenced by the number). If the line doesn't start with ... Then ignore the keypress. I think I can handle all that but I want to know if its possible to: either set up a handler for C-] or must I just :map it? If I must :map it, I can :map so it only affects the current buffer? :bmap? Any help would surely help! Chuck Yes there is a tags file for help, $VIMRUNTIME/doc/tags (and similarly $VIM/vimfiles/doc/tags and/or [on Windows] $HOME/vimfiles/doc/tags if you have installed nonstandard help files locally). Here is (untested) an example of how to map Ctrl-] for only one particular file: function s:ControlBracketHandler() ... endfunction autocmd BufRead C:/path/to/filename.ext \ map buffer C-] :call SIDControlBracketHandler()CR see :help :map-buffer Best regards, Tony.