Monday, September 5, 2011

Re: CTRL-]/CTRL-T to detect existing windows/buffers when switching to/from tags

hi,

On 5 September 2011 22:37, Jacky Liu <bluegene8210@gmail.com> wrote:
> Of course this can be achieved:
>
>        nnoremap! <Ctrl-]> :call <SID>SmartTagSearch()<CR>
>
>        function! s:SmartTagSearch()
>                if {file opened in current tab}
>                        " switch to that window
>                        " locate the tag
>                else
>                        normal! <C-]>
>                endif
>        endfunction
>
> Brief steps implementing s:SmartTagSearch() :
>
> 1. expand() to get the word under the cursor(tag name)
>
> 2. taglist() to get the target file name of the tag
>
> 3. tabpagebuflist() + bufname() to see if that file is opened in the
> current tab, if so the window number is determined
>
> 4. :exe + :normal ^W^W to switch to that window
>
> 5. use the {cmd} got in 1. to locate the tag
>
> Taking all tab pages into account is no problem either, just introduce
> tabpagenr() and :gt
>
> <Ctrl-t> is just the other way round.

Thanks for this - I get the idea, but would you mind expanding it
further? my knowledge of vimscript is zero.

TIA!

--
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

No comments: