Vim使用方法

一.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 <回车>

第七讲小节

  1. 输入 :help 或者按 < F1 > 键 或 < Help > 键可以打开帮助窗口.
  2. 输入 :help cmd 可以找到关于 cmd 命令的帮助.
  3. 输入 CTRL-W , CTRL-W 可以使得您在窗口之间跳转.
  4. 输入 :q 以关闭帮助窗口.
  5. 您可以创建一个vimrc 启动脚本文件用来保存您偏好的设置
  6. 当输入 : 命令时, 按 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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值