linux - 使用 vim,什么是 "' < ,'>"?

标签 linux vim terminal

在使用 Vim 时,在可视模式下,选择文本然后调用冒号命令会显示 : '<,'>而不仅仅是 :正如我在做其他事情(例如打开文件)时所显示的那样。

什么是'<,'>什么意思?

使用 linux (debian) , gnome-terminal , vim7.2

最佳答案

这意味着您在:'<,'> 之后键入的命令将对您选择的文件部分进行操作。

例如,:'<,'>d将删除选定的 block ,而 :d删除光标下的行。

同样,:'<,'>w fragment.txt会将选定的 block 写入名为 fragment.txt 的文件.

两个逗号分隔的东西('<'>)是对应于所选区域的开始和结束的标记。从帮助页面 (:help '<):

                                                       *'<* *`<*
'<  `<                  To the first line or character of the last selected
                        Visual area in the current buffer.  For block mode it
                        may also be the last character in the first line (to
                        be able to define the block).  {not in Vi}.

                                                        *'>* *`>*
'>  `>                  To the last line or character of the last selected
                        Visual area in the current buffer.  For block mode it
                        may also be the first character of the last line (to
                        be able to define the block).  Note that 'selection'
                        applies, the position may be just after the Visual
                        area.  {not in Vi}.

以这种方式使用时,标记只是指定后面命令的范围(参见 :help range )。它们当然可以与其他行号说明符混合和匹配。例如,以下命令将删除从所选区域开始到文件末尾的所有行:

:'<,$d

Vim Wiki 有 more information在 Vim 范围上。

关于linux - 使用 vim,什么是 "' < ,'>"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8898115/

相关文章:

linux - 如何根据时间戳在 linux 中对 csv 文件进行排序?

c++ - 获取/dev/video0的硬件信息

linux - 用于从另一个文件的 block 组成文件的 shell 命令

vim - 什么是vim的@@变量?

vim - 为什么 vundle 需要关闭文件类型

Python 子进程调用返回 "command not found",终端正确执行

c - Linux 内核 - 读/写文件

linux - oracle 一致性段错误

Vim 命令注释掉选定的行?

java - 线程中出现异常 "main"java.lang.UnsatisfiedLinkError : no Terminal in java. library.path