vimium

最近準備使用 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
複製代碼

注意點:

  • 小寫都是在當前頁面打開,大寫都是在新的 tab 打開
  • b/B 只在保存的書籤中進行查找,而 o/O 能夠打開 URL、書籤以及歷史訪問的 URL

查找

/       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 快捷鍵,不然會繼續輸入。

history

至關於瀏覽器的前進/後退功能。

H       go back in history
L       go forward in history
複製代碼

操做 tab

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

左右切換 tab 這個功能特別實用,可是,vimium 在一些特定的頁面中是沒法使用的。因此,當咱們切換到一個沒法使用 vimium 的頁面時,全部關於切換 tab 的快捷鍵都不能用了。這時可使用 Chrome 切換 tab 的快捷鍵切換到容許使用 vimium 插件的頁面,而後再使用 vimium 的切換 tab 功能。

  • Mac - Command + shift + {:向左切換 tab
  • Mac - Command + shift + }:向右切換 tab
  • Windows - Ctrl + tab:向右切換 tab
  • Windows - Ctrl + shift + tab:向左切換 tab

關閉/從新打開 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 選項來查看指令名稱。

特殊字符配置

而特殊按鍵的映射配置遵循一下原則:

  • <c-*>, <a-*>, <m-*> for ctrl, alt, and meta (command on Mac) respectively with any key. Replace * with the key of choice.
  • <left>, <right>, <up>, <down> for the arrow keys.
  • <f1> through <f12> for the function keys.
  • <space> for the space key.
  • <tab>, <enter>, <delete>, <backspace>, <insert>, <home> and <end> for the corresponding non-printable keys (version 1.62 onwards).

例如,在 Mac 機器上,若是要配置 Command + m 爲靜音的快捷鍵,則應該使用下面的方式:

map <m-m> toggleMuteTab
複製代碼

其對應關係以下:

<m-m> toggleMuteTab ====> <Command-m> 切換當前 tab 是否靜音

Mmmm...

基本命令及設置就講這麼多,更高級的用法能夠查看 README

Author 🦉

轉載請註明出處。

相關文章
相關標籤/搜索