首页 \ 问答 \ 如何使vim / vi shift-8用“。”搜索关键字。(how to make vim/vi shift-8 search for keyword with “.”)

如何使vim / vi shift-8用“。”搜索关键字。(how to make vim/vi shift-8 search for keyword with “.”)

我一直使用vim shift-8在courser下搜索关键字。 当关键字很简单,即字母数字+下划线时,它工作正常。 但是,如果有“。” 在关键字中。 它只搜索由“。”分隔的部分关键字。

例如:“ab”,如果我的光标在a上,那么shift-8将搜索“a”。

是否有捷径来搜索整个“ab”?

谢谢


I have always used vim shift-8 to search for the keyword under the courser. It works fine when keyword is simple i.e. alpha-numeric+underscore. However if there is a "." in the keyword. it only search for parts of the keyword delimited by the "."

Ex: " a.b ", if my cursor is on a, then shift-8 will search for "a".

Is there a short cut to search for "a.b" as a whole.

Thanks


原文:https://stackoverflow.com/questions/27573165
更新时间:2022-10-15 13:10

最满意答案

grep的-Z选项似乎只适用于包含匹配内容而不是匹配行内容的文件名。 这对我来说似乎很奇怪,但似乎它是如何运作的。

你实际上并不需要grep (你原来不需要*它也没有添加任何有价值的东西)。

git ls-files采用一种模式来匹配文件名。

所以你想在这里使用这个命令。

git ls-files -z -- '*.js' '*.html'

The -Z option to grep only seems to apply to the filenames that contained the matched content not the content of the matching lines. That seems rather strange to me but that appears to be how it works.

You don't actually need grep here though (you didn't need the * in the original either it didn't add anything of value).

git ls-files takes a pattern to match against the filenames.

So you want to use this command here.

git ls-files -z -- '*.js' '*.html'

相关问答

更多
  • 默认情况下, xargs想要在运行命令之前读取大量参数。 在这种情况下,它可能不是你想要的。 xargs -L1在每个完整的输入行之后运行命令。 By default, xargs wants to read a lot of arguments before running a command with them all. It's probably not what you want in this case. xargs -L1 runs the command after each complete ...
  • 尝试: find . -name '*.py' -exec pylint {} \; | grep "has been rated" Try: find . -name '*.py' -exec pylint {} \; | grep "has been rated"
  • 排序-k5,5将在字段上进行排序并避免切分; uniq -f 4将忽略uniq的前4个字段; 再加上uniq上的-D会让你看到所有重复的行(vs -d,这会让你只有一行); 但uniq会期望制表符分隔而不是csv,所以tr'\ t'','来解决这个问题。 问题是如果你在#5之后有不同的字段。 你的日期都一样长吗? 您可能可以向uniq添加-w 16(包含时间)或-w 10(仅限日期)。 所以: tr '\t' ',' < myfile.csv | sort -k5,5 | uniq -f 4 -D -w 1 ...
  • 使用GNU Parallel,它看起来像这样: cat test5.txt | parallel 'grep {} <(cat test50.txt)' With GNU Parallel it looks like this: cat test5.txt | parallel 'grep {} <(cat test50.txt)'
  • 无.. -r用于递归搜索目录,但-type f将阻止find返回目录名称。 None .. -r is for recursively searching directories, but the -type f will prevent find from returning directory names.
  • 管道不是有条件的,因此您无法根据前一阶段的退出状态禁用后续阶段。 对于您的特定示例,您可以修改find命令以避免需要管道。 find . -iname "*$1*" -exec ack-grep "$2" '{}' + 如果没有匹配的文件,则不会触发exec测试。 Pipes are not conditional, so you can't disable later stages based on the exit status of previous stages. For your particu ...
  • grep的-Z选项似乎只适用于包含匹配内容而不是匹配行内容的文件名。 这对我来说似乎很奇怪,但似乎它是如何运作的。 你实际上并不需要grep (你原来不需要*它也没有添加任何有价值的东西)。 git ls-files采用一种模式来匹配文件名。 所以你想在这里使用这个命令。 git ls-files -z -- '*.js' '*.html' The -Z option to grep only seems to apply to the filenames that contained the match ...
  • 如果没有匹配xargs,那么它将列出当前目录中的所有文件: #----------- current files in the directory mortiz@florida:~/Documents/projects/bash/test$ ls -ltr total 8 -rw-r--r-- 1 mortiz mortiz 585 Jun 18 12:13 json.example2 -rw-r--r-- 1 mortiz mortiz 574 Jun 18 12:14 json. ...
  • 要回答您的问题,可以在需要从一个命令获取输出并将其用作另一个命令的参数时使用xargs 。 在第一个示例中, grep从标准输入中获取数据,而不是作为参数。 所以,不需要xargs 。 xargs从标准输入获取数据并执行命令。 默认情况下,数据作为参数附加到命令的末尾。 但是,它可以插入任何位置,使用占位符进行输入。 传统的占位符是{} ; 使用它,您的示例命令可能会写为: find /etc -name "*.txt" | xargs -I {} ls -l {} 如果/etc有3个文本文件,您将获得每 ...
  • 除非在发布你的问题时这是一个错字,否则sh之前不应该有连字符: 您在输出中没有获取文件名的原因是grep正在以单个文件作为参数运行。 强制文件名输出使用-H 。 find . -name "*.xml" | xargs -I {} sh -c "grep -H FOO {}" 另外,对于xargs -i在4.2.9版本中被弃用。 你应该使用-I {} 。 Unless it's a typo in posting your question there shouldn't be a hyphen befo ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)