在vim中“找到下一个”

本文翻译自:“Find next” in vim

To search forward in vim for cake , I'd type /cake , but the cursor jumps to the first match when I press return. 要在vim中向前搜索cake ,我会输入/cake ,但是当我按下返回时光标跳到第一个匹配。 Is there a vim command analogous to "find next"? 是否有类似于“查找下一个”的vim命令?


#1楼

参考:https://stackoom.com/question/Riwg/在vim中-找到下一个


#2楼

When I was beginning I needed to watch a demo 当我开始时,我需要观看演示

How to search in VIM 如何在VIM中搜索

  1. type / 类型 /
  2. type search term eg "var" 类型搜索词例如“var”
  3. press enter 回车
  4. for next instance press n (for previous N ) 对于下一个实例按n (对于前一个 N

#3楼

As discussed, there are several ways to search: 如上所述,有几种搜索方式:

/pattern
?pattern
* (and g*, which I sometimes use in macros)
# (and g#)

plus, navigating prev/next with N and n . 另外,使用Nn导航prev / next。

You can also edit/recall your search history by pulling up the search prompt with / and then cycle with Cp / Cn . 您还可以通过使用/提取搜索提示来编辑/调用搜索历史记录,然后使用Cp / Cn循环。 Even more useful is q/ , which takes you to a window where you can navigate the search history. 更有用的是q/ ,它会将您带到一个可以浏览搜索历史的窗口。

Also for consideration is the all-important 'hlsearch' (type :hls to enable). 另外需要考虑的是最重要的'hlsearch' (类型:hls to enable)。 This makes it much easier to find multiple instances of your pattern. 这样可以更轻松地找到模式的多个实例。 You might even want make your matches extra bright with something like: 您甚至可能希望通过以下方式使您的比赛变得更加明亮:

hi Search ctermfg=yellow ctermbg=red guifg=...

But then you might go crazy with constant yellow matches all over your screen. 但是你可能会因为整个屏幕上的黄色火柴而疯狂。 So you'll often find yourself using :noh . 所以你经常会发现自己在使用:noh This is so common that a mapping is in order: 这是如此常见以至于映射是有序的:

nmap <leader>z :noh<CR>

I easily remember this one as z since I used to constantly type /zz<CR> (which is a fast-to-type uncommon occurrence) to clear my highlighting. 我很容易记住这个作为z因为我曾经不断地输入/zz<CR> (这是一种快速到类型的罕见事件)来清除我的突出显示。 But the :noh mapping is way better. 但是:noh映射更好。


#4楼

如果在按下“/ wordforsearch”之后按ctrl + enter,则可以在当前行中找到单词“wordforsearch”。然后按n进行下一个匹配;按N进行常规匹配。


#5楼

It is n for next and N for previous. 下一个是n ,之前是N.

And if you use reverse search with ? 如果你使用反向搜索? (eg ?cake ) instead of / , it is the other way round. (例如?cake )代替/ ,反之亦然。

If it is installed on your system, you should try to run vimtutor command from your terminal, which will start a tutorial of the basic Vim commands. 如果它安装在您的系统上,您应该尝试从终端运行vimtutor命令,这将启动基本Vim命令的教程。

Rob Wells advice about * and # is also very pertinent. Rob Wells关于*# 建议也非常贴切。


#6楼

输入n将进入下一场比赛。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值