You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vim中如何反向使用shift-*跳转到光标上方的函数定义?

反向执行Shift-*的Vim快捷键方案

Great question! I deal with this exact situation constantly when digging through long code files where the function definition I need is buried above a ton of other functions.

Here's the quick solution you're looking for:

  • Instead of pressing Shift-* (which maps to the * command, jumping to the next occurrence of the word under your cursor), press Shift-# (the # command). This will jump directly to the previous occurrence of the same word, perfectly targeting definitions that sit above your current cursor position.

A few extra tips to make this workflow smoother:

  • Both * and # use Vim's default word-matching rules (based on your 'iskeyword' setting), so they'll behave consistently with how you're used to jumping to function definitions.
  • Repeat pressing # to keep jumping upward through earlier occurrences if you overshoot or need to check multiple instances.
  • If you accidentally jump too far, hit Ctrl+O to instantly jump back to your previous cursor position—this is a lifesaver for navigating complex codebases.

内容的提问来源于stack exchange,提问作者Chris

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:44:51