最近准备使用 vim 做为开发工具,因而在学习怎样提升 vi 生产力。在学习插件的过程当中先发现一个 Chrome 插件 vimium,在安装后可使用户在 Chrome 浏览器中使用 vi 编辑器中的快捷键。试用以后,惊为天人,所以安利给你们。git
该插件对 vim 中经常使用的快捷键在浏览器中进行了类似的映射,所以对于熟悉 vim 操做的小伙伴来讲,该插件仍是很是容易上手的。github
注:快捷键区分大小写。web
先上安装地址:chrome
快捷键及其描述比较简单,不作过多的翻译。只对其中有歧义的地方进行描述。vim
? show the help dialog for a list of all available keys
h scroll left
j scroll down
k scroll up
l scroll right
gg scroll to top of the page
G scroll to bottom of the page
d scroll down half a page
u scroll up half a page
f open a link in the current tab
F open a link in a new tab
r reload
gs view source - 展现的 vimium 的源码,而不是当前页面的源码
i enter insert mode -- all commands will be ignored until you hit Esc to exit
yy copy the current url to the clipboard
yf copy a link url to the clipboard
gf cycle forward to the next frame
gF focus the main/top frame
复制代码
这里基本都是基本操做,只要牢记 ?
能够唤出全部可用快捷键的帮助信息就行了。浏览器
f/F
这个快捷键值得注意一下。该快捷键会将当前页面上全部的跳转连接用不一样的字母组合标示出来,以下图:编辑器
选择 a
开头的连接:工具
若是选择错了,能够经过 delete
键进行修改。学习
能够在书签中进行搜索真的太方便了。开发工具
o Open URL, bookmark, or history entry
O Open URL, bookmark, history entry in a new tab
b Open bookmark
B Open bookmark in a new tab
复制代码
注意点:
/ enter find mode
-- type your search query and hit enter to search, or Esc to cancel
n cycle forward to the next find match
N cycle backward to the previous find match
复制代码
注:按 /
进入查找后,须要按 回车键 以后才能使用 n/N
快捷键,不然会继续输入。
至关于浏览器的前进/后退功能。
H go back in history
L go forward in history
复制代码
J, gT go one tab left
K, gt go one tab right
g0 go to the first tab
g$ go to the last tab
^ visit the previously-visited tab
t create tab
yt duplicate current tab
x close current tab
X restore closed tab (i.e. unwind the 'x' command)
T search through your open tabs
W move current tab to new window
<a-p> pin/unpin current tab
复制代码
左右切换 tab 这个功能特别实用,可是,vimium 在一些特定的页面中是没法使用的。因此,当咱们切换到一个没法使用 vimium 的页面时,全部关于切换 tab 的快捷键都不能用了。这时可使用 Chrome 切换 tab 的快捷键切换到容许使用 vimium 插件的页面,而后再使用 vimium 的切换 tab 功能。
在 Mac 上,能够经过 Command + w
来关闭 tab;安装了 vimium 后能够经过 x
来关闭 tab;并且,有时咱们手速太快误关了一个 tab 以后,能够经过 X
从新打开刚关闭的页面。
Chrome 本身有一个快捷键来从新打开刚关闭的 tab,可是因为太长了,一直没记住。(捂脸,逃
]], [[ Follow the link labeled 'next' or '>' ('previous' or '<')
- helpful for browsing paginated sites
<a-f> open multiple links in a new tab
gi focus the first (or n-th) text input box on the page
gu go up one level in the URL hierarchy
gU go up to root of the URL hierarchy
ge edit the current URL
gE edit the current URL and open in a new tab
zH scroll all the way left
zL scroll all the way right
v enter visual mode; use p/P to paste-and-go, use y to yank
V enter visual line mode
复制代码
正常的字符键能够直接写其对应的字符,如配置字符 j
为向下滚动页面:
map j scrollDown
复制代码
其中 map
为 vimium 的关键字;j
为要映射的字符按键;scrollDown
为 vimium 中指定向下滚动页面的指令。
vimium 中各类动做的指令名称以下:
在安装了 vimium 的浏览器中,能够经过快捷键 ?
来查看各个快捷键对应的指令;也能够经过帮助信息 dialog 最上面的 Options 选项来查看指令名称。
而特殊按键的映射配置遵循一下原则:
例如,在 Mac 机器上,若是要配置 Command + m
为静音的快捷键,则应该使用下面的方式:
map <m-m> toggleMuteTab
复制代码
其对应关系以下:
<m-m> toggleMuteTab
====> <Command-m> 切换当前 tab 是否静音
基本命令及设置就讲这么多,更高级的用法能够查看 README。
转载请注明出处。