一.Help File
Vim’s online documentation system, accessible via the :help command, is an extensive cross-referenced and hyperlinked reference. It’s kept up-to-date with the software and can answer almost any question about Vim’s functionality.
eg.
:help :vimgrep
5.1 using Vim’s internal grep
:vim :vimgrep E682 E683
:vim [grep] [!] /{pattern}/ [g] [j] {file} …
Search for {pattern} in the files {file} … and set the error list to the matches. Files matching ‘wildignore’ are ignored; file in ‘suffixes’ are searched last.
Without the ‘g’ flag each line is added only once. With ‘g’ every match is added.
{pattern} is a Vim search pattern. Instead of enclosing it in / any non-ID character (see ‘isident’) can be used, so long as it does not appear in {pattern}.
‘ignorecase’ applies. To overrule it put / \c in the pattern to ignore case or / \C to match case.
If {pattern} is empty (e.g. // is specified), the last used search pattern is used.
When a number is put before the command this is used as the maximum number of matches to find.
Use ":1vimgrep pattern file " to find only the first. Useful if you onely want to check if there is a match and quit quickly when it’s found.
Without the ‘j’ flag Vim jumps to the first match. With ‘j’ only the quickfix list is updated. With the [!] any changes in the current buffer are abandoned.
Every second or so the searched file name is displayed to give you an idea of the progress made.
二. Learning Vim playfully
1. http://vim-adventures.com/
2. Vim tutor
See
:help tutor
insede Vim.
e.g.
第四讲第二节:搜索类命令
** 输入 / 加上一个字符串可以用以在当前文件中查找该字符串. **
(1) 在正常模式下输入 / 字符. 您此时会注意到该字符和光标都会出现在屏幕底部, 这跟 : 命令是一样的.
(2) 接着输入 errroor <回车> . 那个errroor 就是您要查找的字符串.
(3) 要查找同上一次的字符串,只需要按 n 键盘. 要向相反方向查找同上一次的字符串, 请输入大写 N 即可.
(4) 如果您想要逆向查找字符串, 请使用 ? 代替 / 进行.
(5) 要回到您之前的位置按 CTRL-O (按住 Ctrl 键 不放同时按下字母 o). 重复按可以回退更多步. CTRL-I 会跳转到较新的位置.
-----> “errroor” is not the way to spell error; errroor is an error.
提示: 如果查找已经到达文件末尾,查找会自动从文件头部继续查找, 除非 ‘wrapscan’ 选项被复位.
提示:如果您想要仅在一次查找时忽略字母大小写,您可以使用 \c:
例如: /errror\c <回车>
第七讲小节
- 输入 :help 或者按 < F1 > 键 或 < Help > 键可以打开帮助窗口.
- 输入 :help cmd 可以找到关于 cmd 命令的帮助.
- 输入 CTRL-W , CTRL-W 可以使得您在窗口之间跳转.
- 输入 :q 以关闭帮助窗口.
- 您可以创建一个vimrc 启动脚本文件用来保存您偏好的设置
- 当输入 : 命令时, 按 CTRL-D 可以查看可能的补全结果.
按< TAB > 可以使用一个补全.
三.技巧
1.如何在vim里搜索关键字
/关键字
按 n键 向下; 按N 向上
2.如何在vim中使用grep
参考
0.https://www.vim.org/docs.php
0.1 Search patterns
https://vim.fandom.com/wiki/Search_patterns
1.Linux如何在vim里搜索关键字
https://blog.csdn.net/sinat_21843047/article/details/89458435