同时按[Alt]+[j] 或[Alt]+[k] 可控制代码向上、向下移。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZQAAACfCAIAAABRF7iAAAAVPElEQVR4nO2d4W8TR/rH/RfwPi94j1SJNyB0yjteHBTIT9Hxhiuokt/Ub05JKqF7kyqUIw0JhQWnvWtjKKlJUhQpokiNFTUvIEqP9twrKbc6pVKbV3cUYoIpNKdzEmxufi/GO56dmV2P7R0743w/eoRgvbM7M/Z+9pnx4okRAACwkFirKwAAAPUAeQEArATyAgBYSUVemUzGcRxCSKFQOHnyZD6fVxbI5/P79u2TX83n8x0dHbFYbNeuXa7r0o2O43R0dAQdKkIcx6GVF8hkMvF4XNgzk8kEHcd13b6+Plb24MGDhUKB3yGo+aBBXNfdvXu367o7sIdZ21tdEcvQklcmk4kFQ12Qz+dPnjz57Nmz7u7uoaEheTdZBBFSVV7sL4K84vG4UEPHcQ4ePJjNZpnF2CnkRoWo2XGceDxeKBQOHjyo7IR4PK6sc4MIZwwxdQuRuyWbzUYlL9rzypdc1921a5fcM+wTTt9QQ29NPB6Xb6V82yM/Y3sTKxQK3d3drusq5RWPxzOZDJ+/CJ8t5gJeXk14G5Qq4aFtUcorkUjwGSLrAV5ksm5oS13X7e7upltCUlS2G71KlQZh5422Z/jDbttbeki3NCgv/g2Sj9zR0UFPmslk2I1HTrENvTX8SUloJwAdAuX1008/dXR0CAogofLih43swtb/LBYKhfn5+VKpVGsb6O1USIL4e3tHR8fExISQLvX19dFPZz6f7+/vZ4eiCRfrDQZrKeuNEHlR6ZNqH1B5VKukpp4RLjxDSUSDmJMX6/nwI+fz+T179tAPqtJTJt4a3p6EENd19+zZs6MGyNHikxe9tg8cOHDgwAF+6qrWYWM2m6X627dvX1dXFxVB1TvMl19+efbs2ampqZr8RQ3S7yG8Sj+C1G78sJH/yPJ16+/vn5iYiMfj/f39tP75fD68+bFYTPiU8weXr1I+GwpJE+ruGaW8aDUmJiY6OjpolsFuNjH/4Je/CQ0NDdGd5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o/0vPkBeIEnMLcASveRG+AEd4NYJK8e2plPbqpjym/olqwqC8xsZSpVLJp63NTWquwsZmsVgcufC+xiEbWY/D/8vOYb9hX6UtADSC2QU4SMCaF1UX4Ggk8woa/LVH5vXRxx8XSyXeXAXPXIXCxsti8fzIiM4xG1iPA/ICrcfwAhzy2biELHwBDu0ftJd1Eygg5THNLOZoUF5/+eijYqm0sVHJtmj8t7Dx38LGy2Jx6Pyw1kHrX49DWFODX4BjLok5L9AEtvMCHKHVCC6l2qCsmzJRjO5HXg3K68M//6VYLBV85tqg5qLyGhw6r3fUutfjkBYEqizAUX2xDcgLREAzFuAIWCaj6gIcodWoVkp+4kxegoPbR+9ENWFQXh98+GFFXoWKtpi8zr33XkStMALkBbYn+BF7ikF5JT/44GWxGBJnzw1G2ZSogbzAtgTuKmNQXleSo86VK5ecyxcvORfevzhy4f3zIyND54cHh86fe++9s+cG3/3TOfkI7Dmsli+lCHkBsJ0xKC/baae2ANB+QF6BtFNbAGg/IK9A2qktALQfkFcg7dQWANoPyCuQdmoLAO0H5BVIO7UFgPYD8gqkndoCQPuBn4GuHpF2OAAgGiAvyAsAK4G8IC8ArMTgorMAAGAOyAsAYCWQFwDASiAvAICVQF4AACuBvAAAVgJ5AQCsBPICAFgJ5AUAsBLICwBgJZAXAMBKIC8AgJVAXgAAK4G8AABWAnkBAKwE8gIAWAnkBQCwEsgLAGAlkBcAwEogLwCAlUBeAAArgbwAAFYCeQEArATyAgBYCeQFALASyAsAYCX/D/hKbX1SNYw0AAAAAElFTkSuQmCC" alt="" />
基础
字符移动
k 上移 k
h 左移 h l
l 右移 j
j 下移
你也可以使用键盘上的方向键来移动,但这么做h j k l的存在就失去了意义
之所以使用h j k l来控制方向,其主要目的是让你的手不离开键盘中心,从而提高效率
tips:在命令前加上数字代表命令执行次数,如:5k,表示上移5行
单词移动
W w 移动到下一个单词开头
E e 移动到下一个单词结尾
B b 倒退到上一个单词开头
需要注意的是,E会忽略标点符号,如:I‘m,e会当成两个单词,E则不会
同样,在命令前加上数字代表执行次数,如:2w,表示往下移动2个单词
开头我也许会多说几遍,因为这个技巧很重要
整行移动
0 移动到行首
$ 移动到行末
+ 移动到下一行开头
- 移动到上一行开头
这里需要注意的是+ -和上面的j k有什么不同之处
j k也是移动到上一行和下一行,但它们移动的是光标所在的位置
+ -不管你的光标在何处,总是移动到下一行或上一行的行首
进阶
滚屏
Ctrl+f 往前滚动一整屏
Ctrl+b 往后滚动一整屏
Ctrl+d 往前滚动半屏
Ctrl+u 往后滚动半屏 Ctrl+e 往后滚动一行
Ctrl+y 往前滚动一行
看似比较多,但是可以根据键盘的位置来进行记忆,并且下面两个也不常用
上面的滚屏都有一个共同点,就是会改变光标的位置,且屏幕也在改变
如果想让光标维持在原来的位置实现滚屏请看下面
用z调整光标
z<Enter> 将光标所在行移动到屏幕顶端
z. 将光标所在行移动到屏幕中间
z- 将光标所在行移动到屏幕低端
tips:980z<Enter>可以将第980行移动到屏幕顶端
好吧,有时候你其实不想滚屏,你只想在当前屏幕中移动
请往下看
在屏幕中移动
H 移动到屏幕顶端的行
M 移动到屏幕*的行
L 移动到屏幕底端的行 nH 移动到屏幕顶端往下的第n行
nL 移动到屏幕顶端往上的第n行
据我猜测这三个字母应该是HIgh、Middle和Low的缩写,其实挺好记的
多练习几遍就行了,需要注意的是:这里只是光标的位置变化,和上面两种不同
tips:你可以用+ -和j k实现同样的位置变化,只不过要操作多次而已
+ -和j k的区别忘了吗?往上看看吧
在当前行移动
^ 移动到当前行的第一个非空格处
n| 移动到当前行的第n列
这里的^与上面的0通常情况下表示的位置是一样的
而n|,个人感觉还没有h l方便,慢慢的数出行数还不如直接按着h l 左右移
根据文本块移动
所谓的文本块也就是句子、段落、小节等
( 移动到当前句子开头
) 移动到下一个句子开头
{ 移动到当前这一段开头
} 移动到下一段开头
[[ 移动到当前这一节的开头
]] 移动到下一节的开头
其中,VIM以? . !等符号来标记一个句子
空白行来标记一个段落
用节宏来标记一个节(节宏是什么我还没搞清楚)
根据行号来移动
Ctrl+g 显示当前行信息
nG 转至第n行
G 转至文本末尾
gg 移至文本开头
如果你不知道当前是多少行的话就可以用Ctrl+g来查看
如果想转到第800行,可以用800G
其实z命令也可以做到,并且把光标移动到第一行
tips:``反引号可以返回到使用G之前的位置