Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
Jump to a function from where it is called
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
Jump to a function from where it is called
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{TipImported |id=383 |previous=382 |next=384 |created=2002 |complexity=basic |author=zzapper |version=6.0 |rating=0/7 |category1= |category2= }} When writing/debugging code you often want to jump from where a subroutine/function is called to where it actually is . Hitting the "*" key is frustrating if the sub/func is called many times. The following mapping solves the problem. (Notice how it can be altered for other languages) nmap gx yiw/^\(sub\<Bar>function\)\s\+<C-R>"<CR> Instructions: Place cursor over called function (normal mode) and type <code>gx</code> ==How it works== ;yiw : Yank inner work to un-named register ;/^\(sub\<Bar>function\)\s\+ : search for sub or function followed by 1 or more spaces ;<C-R>" : Retrieve un-named register ;<CR> : Start Search Information also included in [[VimTip305]]. ==References== *{{help|tags-and-searches}} *{{help|tag=g%5D|label=g]}} ==Comments== What language is this supposed to work in? Basic?? :Probably perl, which also uses sub for functions ---- I suggest to modify mapping: nmap gx mryiw/^\(sub\<Bar>function\)\s\+<C-R>"<CR> thus allowing reverse jump by typing `r ---- I think this would be much better accomplished using Vim's excellent Ctags interface. {{help|ctags}}. Exuberant Ctags has support for Perl. --[[User:Fritzophrenic|Fritzophrenic]] 20:03, 18 February 2009 (UTC) To use ctags: ctags -R -n --fields=+i+K+S+l+m+a --exclude=src/react/conf-srch/node_modules then in vim :tag <<the_sub_name_to_jum_to>>
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Help
(
view source
)
Template:Navigation
(
view source
)
Template:TipImported
(
view source
)
Follow on IG
TikTok
Join Fan Lab