vim快速移动
移动基本移动1、方向键:上下左右可以实现光标移动
基于单词移动
如下图: 对字符进行查找进行移动Vim 的字符查找命令让我们可以在行内快速移动,并且它们能够在操作符待决模式下很好地工作。
更强大的查找命令/ ;n、N对其进行前后移动 设置标记位移动m{a-zA-Z} 命令会用选定的字母标记当前光标所在位置 *m* *mark* *Mark*
m{a-zA-Z} Set mark {a-zA-Z} at cursor position (does not move
the cursor,this is not a motion command).
*m'* *m`*
m' or m` Set the previous context mark. This can be jumped to
with the "''" or "``" command (does not move the
cursor,this is not a motion command).
*m[* *m]*
m[ or m] Set the |'[| or |']| mark. Useful when an operator is
to be simulated by multiple commands. (does not move
the cursor,this is not a motion command).
*:ma* *:mark* *E191*
:[range]ma[rk] {a-zA-Z'}
Set mark {a-zA-Z'} at last line number in [range],column 0. Default is cursor line.
Jumping to a mark can be done in two ways:
1. With ` (backtick): The cursor is positioned at the specified location
and the motion is |exclusive|.
2. With ' (single quote): The cursor is positioned on the first non-blank
character in the line of the specified location and
the motion is linewise.
vim自动标记位
匹配括号跳转Vim 提供了一个动作命令,让我们可以在开、闭括号间跳转。在激活了 matchit.vim插件后,此命令也可以用于成对的 XML 标签,以及某些编程语言中的关键字上 :h %查看详细帮助
跳转动作命令在一个文件内移动,而跳转则可以在文件间移动 遍历跳转列表:jumps :jumps
jump line col file/text
91 7 4 kk.sh
90 1 0 ~/codeTmp/pdlapi-statisfaction/conf/service.properties
89 1 0 ~/codeTmp/pdlapi-statisfaction/conf/deploy.properties
88 1 0 ~/codeTmp/pdlapi-statisfaction/conf/db.ext.properties
87 38 0 ~/codeTmp/pdlapi-statisfaction/conf/db.ext.properties
……
任何改变当前窗口中活动文件的命令,都可以被称为跳转命令。Vim 会把执行跳转命令之前和之后的光标位置,记录到跳转列表中
Vim 可以同时维护多份跳转列表。实际上,每个单独的窗口都拥有一份自己的跳转列表。 遍历改变列表每当对文档做出修改后,Vim 都会记录当时光标所在的位置。遍历改变列表的方法很简单,并且这大概是跳到你要去的地方的最快方式。 :changes
change line col text
11 1 0 #!/bin/bash
10 2 3 #add
9 12 0 readonly cur_date="`date +%Y%m%d`"
8 11 0 #readonly cur_date="`date +%Y%m%d`"
7 19 12 echo "total Memory: $total_mem total cpu: $total_cpu"
6 20 0 o#add^[kdkdkdkdkdkdkdkdkdyypkui#^[kdkdkdkdkdkdkdkukrkrkrkrkrkrkrkrkrkrkrkrkdkdrM^[
5 23 0 for pid in `ps -ef | awk 'NR > 0 {print $2}'` ; do
4 29 0 o#add^[kdkdkdkdkdkdkdkdkdyypkui#^[kdkdkdkdkdkdkdkukrkrkrkrkrkrkrkrkrkrkrkrkdkdrM^[
3 23 0 for pid in `ps -ef | awk 'NR > 0 {print $2}'` ; do
2 23 0 for pid in `ps -ef | awk 'NR > 0 {print $2}'` ; do
1 23 0 for pid in `ps -ef | awk 'NR > 0 {print $2}'` ; do
>
Press ENTER or type command to continue
标记上次修改方位的位置标记Vim 会自动创建一些位置标记,它们是对改变列表的一个有用补充。 *'^* *`^*
'^ `^ To the position where the cursor was the last time
when Insert mode was stopped. This is used by the
|gi| command. Not set when the |:keepjumps| command
modifier was used. {not in Vi}
*'.* *`.*
'. `. To the position where the last change was made. The
position is at or near where the change started.
Sometimes a command is executed as several changes,then the position can be near the end of what the
command changed. For example when inserting a word,the position will be on the last character.
{not in Vi}
在大多数场景下,跳转到`. 的效果与使用g; 命令相同。不过位置标记只指向最后修改的位置,而改变列表中则保存了多组位置。我们可以多次按g; 命令,每次它都会把我们带到改变列表中较早的一个位置,而`. 则总是把我们带到改变列表的最后一项。 未完待续…… (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |