Friday, December 18, 2009

Re: To print module's name

2009/12/18 Bu Rak <lokumcu@gmail.com>:
> Hi,
>
> While browsing in verilog or vhdl code, there is a need to get which
> "module" or "entity" (these are the required keywords) the line is.
>
> My solution is maybe writing a function and map a key to call this function.
>
> Any example code for the function would be very well...

This isn't a direct answer to your question, but there's some code
below that handles this for C/C++ etc. It may even work for VHDL if
you indent in a similar way. If you change the line starting echo
getline(search... to have a slightly different regular expression in
the first set of double quotes, you should be able to make it do what
you want. At the moment it searches for a line that starts with at
least two non-(space/tab/#/slash) characters that doesn't end in a
colon (this works quite well for a lot of indented languages).

Al

" Show the name of the current function
nmap ,f :call ShowFuncName()<CR>

" Show the name of the current function (designed for C/C++, Perl, Java etc)
fun! ShowFuncName()
let lnum = line(".")
let col = col(".")
echohl ModeMsg
echo getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW'))
echohl None
call search("\\%" . lnum . "l" . "\\%" . col . "c")
endfun


--
http://sites.google.com/site/abudden

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: