如何使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
最满意答案
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.
-
如何在输出管道的第一个命令时不输出任何内容(How to not output anything when the first command of a pipe does not output)[2022-08-31]
管道不是有条件的,因此您无法根据前一阶段的退出状态禁用后续阶段。 对于您的特定示例,您可以修改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输出管道输出到xargs(Pipe grep output to xargs)[2023-12-03]
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 ... -
grep -l在xargs管道上的行为不像预期的那样[复制](grep -l does not behave as expected on piping to xargs [duplicate])[2022-02-14]
如果没有匹配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?(When to use xargs when piping?)[2022-09-15]
要回答您的问题,可以在需要从一个命令获取输出并将其用作另一个命令的参数时使用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 ...