Nevermind.. It took a bit of googling to find other people doing
similar things.

The below seems to have done the trick :-)
exe "tag " . module

I am still curious to know why my earlier methods failed though.


On Feb 10, 10:17 pm, Mahurshi Akilla <[email protected]> wrote:
> Thanks for the detailed response.  I have tried this and it worked
> very well and saved a lot of time!!!  I am using :call method to call
> the function because I found it most readable.
>
> I now have a tags file for everymoduleso it is easy to navigate back
> and forth between files.  I tried to modify the function you gave by
> replacing the echo statement with a tag command so I could just go to
> thatmodule'sfile by just pressing a key ;-)
>
> I wanted to replace:
>   echo printf("module: %s,instance: %s",module,instance)
>
> With:
> tag module
>
> This, of course, didn't work.  :-(
>
> I tried using $module, @module, <module>, `module.. but nothing
> worked.  It was literally looking for what I typed next to "tag" but
> not looking for what the variable "module" contained.
>
> It looks like I don't even know how to call a variable in this
> language. :-)  Could you pl. let me know what I should do here to
> access themodulevariable and "tag" to it?
>
> On Jan 31, 3:39 am, Andy Wokula <[email protected]> wrote:
>
> > Mahurshi Akilla schrieb:
>
> > > I found the following map command on a wiki, which tells themodule
> > > name in a verilog file when F6 is pressed.
>
> > > map <F6> ma?^\s*\<module\><CR>Wyiw'a:echo "module-->" @0<CR>
> > > (source:http://vim.wikia.com/wiki/For_verilog_users_only)
>
> > > I would like to have a similar map statement match aninstancename
> > > when F6 is pressed since it is more useful to me.
>
> > > Basically, I want it to match something like:
>
> > > ^\s*([A-Za-z0-9\_]+)\s+(\S+)\s*(
>
> > As avimpattern:
> >     ^\s*\(\w\+\)\s\+\(\S\+\)\s*(
>
> > or in "very magic" notation (which looks more like perl):
> >     \v^\s*(\w+)\s+(\S+)\s*\(
>
> > Vimpatterns:
> >     :h pattern
> >     :h /\w
> >     :h magic
>
> > > That is how I would describe this as a perl regexp.  I want to match
> > > both $1 and $2 and have it print something like:  module: $1,
> > >instance: $2
>
> > > I am aware that the regexp is not foolproof but it should be okay for
> > > me for now..
>
> > > I am not sure how I can translate this to the above map statement.
> > > Could anyone provide some help?  Thanks.
>
> > (1) Here is a somewhat direct translation:
>
> >     :no <silent><F6> ma?\v^\s*(\w+)\s+(\S+)\s*\(<CR>^"myeW"iyt(`a
> >         \:echo printf("module: %s,instance%s", @m,@i)<CR>
>
> > Split for easier reading:
> >     ma
> >     ?\v^\s*(\w+)\s+(\S+)\s*\(<CR>
> >     ^
> >     "mye
> >     W
> >     "iyt(
> >     `a
>
> > The grouping parens are kept in the pattern, although not used here.
> > The Normal mode commands
> >     ^"myeW"iyt(
> > walk over what has been matched, but without knowing anything about the
> > pattern.  It's not exact anyway, "iyt(  might include the white space
> > before (.
>
> > (2) The following version uses a function.  It doesn't touch marks,
> > registers or the last search pattern; and it keeps the view of the
> > current window (as it doesn't move the cursor).
>
> > map <silent> <F6> :call Verilog_EchoModule()<CR>
>
> > func! Verilog_EchoModule()
> >     let pat = '\v^\s*(\w+)\s+(\S+)\s*\('
> >     let mod_lnum = search(pat, 'bWn')
> >     if mod_lnum > 0
> >         let [module,instance] = matchlist(getline(mod_lnum), pat)[1:2]
> >         echo printf("module: %s,instance: %s",module,instance)
> >     else
> >         echo "Couldn't determinemodule/instance"
> >     endif
> > endfunc
>
> > Slightly other ways to map <F6>:
>
> > if you put the mapping and the function into after/ftplugin/verilog.vim
> > (filetype=verilog), a buffer local mapping is recommended:
> >     :map <buffer><silent> <F6> :call Verilog_EchoModule()<CR>
>
> > A safer way to map <F6>:
> >     :noremap <buffer><silent> <F6> :<C-U>call Verilog_EchoModule()<CR>
>
> > c_CTRL-U
> > <C-U> removes the range that is inserted after {count}<F6>, or if <F6>
> > was pressed from Visual mode.  A range doesn't hurt, but it would call
> > the function for every line in the range (moving the cursor).
>
> > :map vs. :noremap
> > noremap is like map with disallowed remapping of keys on the right hand
> > side of the mapping.  http://vim.wikia.com/wiki/For_verilog_users_only
> > itself provides a good example why :noremap often is better than :map.
> > I wondered why they use 'a, where `a would be much better for jumping
> > back.  The obvious reason: The original mapping was:
> >     :map ` ma?module<CR>Wyiw'a:echo "module-->" @0<CR>
> > Thus ` is a key that must not occur on the right hand side, unless
> > recursion is wanted (which isn't of course).  With :noremap you don't
> > need the work around:
> >     :noremap ` ma?module<CR>Wyiw`a:echo "module-->" @0<CR>
>
> > --
> > Andy
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to