chrome 怪异插件 cVim,多用键盘快捷键,上网冲浪解放鼠标,

技术文摘

前言

现在面向电脑工作,当然用到键盘,鼠标??,碰到问题就得上网搜索。真正提供效率的很开手不离键盘,除了 thinkpad 的小红点,还有就是多用快捷键,省去用鼠标点击的时间,因为用鼠标点,再来回输入,费事。

chrome 的插件 cVim就是这样的。让你在浏览网页时候不用鼠标操作。

当然之所以叫怪异,因为有学习成本,连续使用七小时形成使用习惯。

当然,习惯了就离不开。

chrome 的插件现在也使用与用 chromium 核心的其他浏览器,如 360,qq,(安装方法可能不一样)

chrome的 从商店安装, 如果打不开,可以搜离线下载方法,?→点击

或下载后自行添加,

git的压缩文件    源码

如果下载不了,试试浏览器的云加速或迅雷高速下载

本地下载

手动安装:可以在此处下载.zip文件,并通过转到chrome://extensions URL并选中开发人员模式来启用cVim,然后通过“加载解压的扩展程序…”按钮将Chrome指向解压缩的文件夹。

↓以下来自 readme.md,机翻加命令注释。

装完后地址栏输入 chrome-extension://ihlenndgcmojhcghmfjfneahoeklbjjh/pages/mappings.html#cvimrc


使用指南

使用方法?官方的 readme 很全了,复制过来。

Vim for Google Chrome。 我讨厌使用鼠标,尤其是在学习Vim之后。 在台式机(Linux)上,我有许多按键绑定使操作变得更容易:我用Alt + w打开Chrome,我用Alt + Shift + d关闭了一个窗口,我用Alt + t打开了一个终端。 使用Chrome很难做到这一点,因为它没有用于自定义键盘快捷键的部分,并且仍然需要使用鼠标来执行诸如单击链接之类的操作。 cVim旨在尽最大努力消除此问题,例如Chrome扩展程序API所允许的。

为什么这与Vimium,ViChrome或Vrome不同?

这些扩展在将类似于Vim的键绑定添加到Google Chrome方面做得很好,但是它们缺少Firefox插件Pentadactyl所具有的许多功能。

cVim可为Chrome添加哪些功能?

Google / IMDB / Wikipedia / Amazon / Duckduckgo / Yahoo / Bing搜索完成

支持自定义搜索引擎

具有书签文件夹支持的历史记录和书签搜索/完成

插入符/可视模式

高效的链接提示(支持自定义映射)

支持自定义键盘映射

正则表达式页面搜索,突出显示

带有制表符补全的命令栏

平滑滚动


cVim 帮助

cVimrc

  • Boolean cVimrc settings are enabled with the command 'set' + <SETTING_NAME> and disabled with the command 'set' + no<SETTING_NAME> (for example, set regexp and set noregexp)
  • Boolean cVimrc settings can be inversed by adding “!” to the end
  • Other settings are defined with = used as a separator and are prefixed by let (for example, let hintcharacters="abc")
设置类型描述默认
searchlimitinteger

设置命令栏中显示的结果数量

25
scrollstepinteger

设置使用向上滚动和向下滚动命令时滚动的像素数量

70
timeoutlenintegerThe amount of time to wait for a <Leader> mapping in milliseconds1000
fullpagescrollpercentinteger设置使用scrollFullPageUp和scrollFullPageDown命令时要滚动的页面的百分比0
typelinkhintsdelayinteger打开启用了typelinkhints和numerichints的链接提示后,输入之前等待的时间(以毫秒为单位)300
scrolldurationinteger平滑滚动的持续时间500
vimportintegerset the port to be used with the editWithVim insert mode command8001
zoomfactorinteger / double放大/缩小页面时的步长0.1
scalehintsboolean对链接提示进行动画处理false
hudboolean

显示提醒显示

true
regexpboolean

在find模式中使用正则表达式

true
ignorecaseboolean

在find模式下忽略搜索大小写

 
true
linkanimationsboolean当链接提示打开和关闭时显示淡入淡出效果false
numerichintsboolean使用数字作为链接提示,而不是一组字符false
dimhintcharactersboolean暗号匹配提示字符,而不是将它们从提示中删除true
defaultnewtabpageboolean使用默认的chrome://newtab页而不是空白页false
cncpcompletionboolean使用<C-n>和<C-p>循环浏览完成结果(要求您在 chrome://extensions页(右下)中设置nextCompletionResult键绑定false
smartcaseboolean不区分大小写的查找模式搜索,除非输入包含大写字母true
incsearchboolean输入长度大于两个字符时,开始自动突出显示查找模式匹配true
typelinkhintsboolean(需要数字提示)在链接中键入文本以缩小数字提示false
autohidecursorboolean滚动时隐藏鼠标光标(对于Linux有用,它不会在keydown时自动隐藏光标)false
autofocusboolean允许网站在首次加载时自动使输入框具有焦点true
insertmappingsboolean使用插入映射在文本框中导航光标(请参见下面的绑定)true
smoothscrollboolean使用平滑滚动false
autoupdategistboolean如果使用GitHub Gist同步设置,则每小时(以及Chrome重新启动时)提取更新false
nativelinkorderboolean

像Chrome一样打开新标签页,而不要打开当前打开的标签页旁边的标签页

false
showtabindicesboolean标签标题中显示标签索引false
sortlinkhintsboolean

按链接距页面左上角的距离对链接提示字母进行排序

false
localconfigboolean从configpath读取cVimrc配置(设置此选项后,您无需从cVim的选项页面中保存false
completeonopenboolean打开命令栏时自动显示命令完成列表false
configpathstring

设置configpath时,从此本地文件中读取cVimrc

“”
changelogboolean

更新cVim时自动打开变更日志

true
completionenginesarray of strings仅使用指定的搜索引擎[“google”, “duckduckgo”, “wikipedia”, “amazon”]
blacklistsarray of strings在与其中一种模式匹配的网站上禁用cVim[]
mapleaderstring默认的<Leader> 键\
defaultenginestring设置默认搜索引擎“google”
localestring设置要完成/搜索的站点的语言环境(请参见下面的示例配置)“”
homedirectorystringthe directory to replace ~ when using the file command“”
qmark <alphanumeric charcter>string添加持久性QuickMark

(e.g. let qmark a = ["http://google.com", "http://reddit.com"])

none
previousmatchpatternstring (regexp)浏览页面的后退按钮时查找的模式((?!last)(prev(ious)?|newer|back|«|less|<|‹| )+)
nextmatchpatternstring (regexp)导航页面的下一个按钮时寻找的模式((?!first)(next|older|more|>|›|»|forward| )+)
hintcharactersstring (alphanumeric)设置在链接提示模式下使用的默认字符“asdfgqwertzxcvb”
barpositionstring [“top”, “bottom”]设置命令栏的默认位置“top”
langmapstring设置要重新映射的字符列表(请参见vims langmap)“”

示例配置

" Settings
set nohud
set nosmoothscroll
set noautofocus " The opposite of autofocus; this setting stops
                " sites from focusing on an input box when they load
set typelinkhints
let searchlimit = 30
let scrollstep = 70
let barposition = "bottom"
let locale = "uk" " Current choices are 'jp' and 'uk'. This allows cVim to use sites like google.co.uk
                  " or google.co.jp to search rather than google.com. Support is currently limited.
                  " Let me know if you need a different locale for one of the completion/search engines
let hintcharacters = "abc123"
let searchengine dogpile = "http://www.dogpile.com/search/web?q=%s" " If you leave out the '%s' at the end of the URL,
                                                                    " your query will be appended to the link.
                                                                    " Otherwise, your query will replace the '%s'.
" This will do the same thing as above, except typing ':tabnew withbase' into to command bar
" without any search parameters will open 'http://www.dogpile.com'
let searchengine withbase = ["http://www.dogpile.com", "http://www.dogpile.com/search/web?q=%s"]
" alias ':g' to ':tabnew google'
command g tabnew google
let completionengines = ["google", "amazon", "imdb", "dogpile"]
let searchalias g = "google" " Create a shortcut for search engines.
                             " For example, typing ':tabnew g example'
                             " would act the same way as ':tabnew google example'
" Open all of these in a tab with `gnb` or open one of these with <N>goa where <N>
let qmark a = ["http://www.reddit.com", "http://www.google.com", "http://twitter.com"]
let blacklists = ["https://mail.google.com/*", "*://mail.google.com/*", "@https://mail.google.com/mail/*"]
" blacklists prefixed by '@' act as a whitelist
let mapleader = ","
" Mappings
map <Leader>r reloadTabUncached
map <Leader>x :restore<Space>
" This remaps the default 'j' mapping
map j scrollUp
" You can use <Space>, which is interpreted as a
" literal " " character, to enter buffer completion mode
map gb :buffer<Space>
" This unmaps the default 'k' mapping
unmap k
" This unmaps the default 'h', 'j', 'k', and 'l' mappings
unmap h j k l
" This remaps the default 'f' mapping to the current 'F' mapping
map f F
" Toggle the current HUD display value
map <C-h> :set hud!<CR>
" Switch between alphabetical hint characters and numeric hints
map <C-i> :set numerichints!<CR>
map <C-u> rootFrame
map <M-h> previousTab
map <C-d> scrollPageDown
map <C-e> scrollPageUp
iunmap <C-y>
imap <C-m> deleteWord
" Create a variable that can be used/referenced in the command bar
let @@reddit_prog = 'http://www.reddit.com/r/programming'
let @@top_all = 'top?sort=top&t=all'
let @@top_day = 'top?sort=top&t=day'
" TA binding opens 'http://www.reddit.com/r/programming/top?sort=top&t=all' in a new tab
map TA :tabnew @@reddit_prog/@@top_all<CR>
map TD :tabnew @@reddit_prog/@@top_day<CR>
" Use paste buffer in mappings
map T :tabnew wikipedia @"<CR>
" Code blocks (see below for more info)
getIP() -> {{
httpRequest({url: 'http://api.ipify.org/?format=json', json: true},
function(res) { Status.setMessage('IP: ' + res.ip); });
}}
" Displays your public IP address in the status bar
map ci :call getIP<CR>
" Script hints
echo(link) -> {{
alert(link.href);
}}
map <C-f> createScriptHint(echo)
let configpath = '/path/to/your/.cvimrc'
set localconfig " Update settings via a local file (and the `:source` command) rather
                " than the default options page in chrome
" As long as localconfig is set in the .cvimrc file. cVim will continue to read
" settings from there

黑名单

黑名单设置使用Chrome的@match模式准则的自定义实现。有关语法的说明,请参见https://developer.chrome.com/extensions/match_patterns

站点特殊配置选项

您可以使用上述黑名单匹配模式为网站启用某些rc设置

" this will enable the config block below on the domain 'reddit.com'
site '*://*.reddit.com/*' {
unmap j
unmap k
set numerichints
}

页面加载时运行命令

与上面描述的特定于站点的配置类似,cVim可以在页面加载call关键字时运行命令

" In this case, when pages with a file ending in '.js' are loaded,
" cVim will pin the tab and then scroll down
site '*://*/*.js' {
call :pintab
call scrollDown
}
 

映射

使用以下结构定义法线映射:map <KEY> <MAPPING_NAME>

插入映射使用相同的结构,但使用命令“ imap”而不是“ map”

还可以使用Control,Meta和Alt:

<C-u> ” Ctrl + u
<M-u> ” Meta + u
<A-u> ” Alt + u

也可以使用unmap <KEY>取消映射默认绑定,并使用iunmap <KEY>插入绑定。

要取消映射所有默认键绑定,请使用unmapAll。 要取消映射所有默认插入绑定,请使用iunmapAll

标签

打开链接(:tabnew 和 :open)的命令具有三个不同的属性

! =>在新标签页中打开

$ =>在新窗口中打开

| =>在隐身窗口中打开

&=>在新标签页中打开(无效/未聚焦)

* =>固定标签

? =>将查询视为搜索

= =>将查询视为URL

这些属性的用法最好通过示例进行说明 

:open! gg<CR> " 类同 :tabnew google<CR>
:open gg!<CR> " 这是上面写的另一种方式
                  " (这些标志可以添加到要么
                  " 基本命令或最终命令的结尾)
:open& gg<CR> " 这将在新的非活动标签中打开Gg
:open$ gg<CR> " 这将在新窗口中打开 gg
:open&* gg<CR> " 将会在一个新的不活动的固定标签中打开Gg
:tabnew gg&*<CR> " 再一次,这将与上述命令执行相同的操作
:open gg&*<CR> " 再次,
:open gg!& " Here, the & flag will cancel out the ! flag,
               " opening gg in a new inactive tab
" 更多示例
:bookmarks my_bookmark.com&  " 不激活,新标签
:bookmarks&* my_bookmark.com " 不激活,固定,新标签
:bookmarks! my_bookmark.com  " 新标签
:bookmarks$ my_bookmark.com  " 新窗口
:bookmarks my_bookmark.com   " 当前标签

代码块

代码块使您可以通过cVimrc与cVim的内容脚本进行交互。

由于代码块使用eval(…),因此只有在知道自己在做什么的情况下才应使用它们。

" To be used by the code block
set hintset_a
" Create a code block named switchHintCharacters
switchHintCharacters -> {{
// We are now in JavaScript mode
// Settings are contained in an object named settings
settings.hintset_a = !settings.hintset_a;
if (settings.hintset_a) {
settings.hintcharacters = 'abc'; // equivalent to "let hintcharacters = 'abc'"
} else {
settings.hintcharacters = 'xyz';
}
// Propagate the current settings to all tabs for the
// rest of the session
PORT('syncSettings', { settings: settings });
// Display cVim's status bar for 2 seconds.
Status.setMessage('Hint Set: ' + (true ? 'a' : 'b'), 2);
}}
" Run the JavaScript block
map <Tab> :call switchHintCharacters<CR>

自动完成引擎

这些是可以在命令栏中使用的完成引擎的列表。 可以通过使用完成引擎变量将其名称分配给数组来设置它们。

google, wikipedia, youtube, imdb, amazon,
google-maps, wolframalpha, google-image,
ebay, webster, wictionary, urbandictionary, 
duckduckgo, answers, google-trends, google-finance, 
yahoo, bing, themoviedb

用法示例:

let completionengines = [‘google’, ‘google-image’, ‘youtube’] ” 在命令栏中仅显示这些引擎

快捷键绑定

Movement Mapping name
js向下滚动scrollDown
kw向上滚动scrollUp
h向左滚动scrollLeft
l向右滚动scrollRight
d向下滚动半页scrollPageDown
unmapped向下滚动整页scrollFullPageDown
ue向上滚动半夜scrollPageUp
unmapped向上滚动全页scrollFullPageUp
gg滚动页面顶部scrollToTop
G滚动页面底部scrollToBottom
0滚动页面左边scrollToLeft
$滚动页面右边scrollToRight
#滚动页面焦点到主要resetScrollFocus
gi去第一个输入框goToInput
gI去最后一个输入框 gigoToLastInput
zzcenter page to current search match (middle)centerMatchH
ztcenter page to current search match (top)centerMatchT
zbcenter page to current search match (bottom)centerMatchB
Link Hints  
f在当前标签打开链接createHint
F新标签中打开链接createTabbedHint
unmapped新标签中打开链接 激活createActiveTabbedHint
W新窗口打开链接createHintWindow
A重复上一个提示命令openLastHint
q触发悬停命令 (mouseover + mouseenter)createHoverHint
Q触发取消悬停命令 (mouseout + mouseleave)createUnhoverHint
mf打开多个链接createMultiHint
unmapped使用外部编辑器打开文本createEditHint
unmappedcall a code block with the link as the first argumentcreateScriptHint(<FUNCTION_NAME>)
unmapped新标签中打开图像fullImageHint
mr反向图像搜索多个链接multiReverseImage
my拖拽多个链接(用P打开链接列表)multiYankUrl
gy复制 url 链接到剪贴板yankUrl
grreverse image search (google images)reverseImage
;change the link hint focus 
QuickMarks  
M<*>create quickmark <*>addQuickMark
go<*>open quickmark <*> in the current tabopenQuickMark
gn<*>open quickmark <*> in a new tabopenQuickMarkTabbed
gw<*>open quickmark <*> in a new windowopenQuickMarkWindowed
Miscellaneous  
aalias to “:tabnew google “:tabnew google
.repeat the last commandrepeatCommand
:open command baropenCommandBar
/open search baropenSearchBar
?open search bar (reverse search)openSearchBarReverse
unmappedopen link search bar (same as pressing /?)openLinkSearchBar
Isearch through browser history:history
<N>g%scroll <N> percent down the pagepercentScroll
<N>unmappedpass <N> keys through to the current pagepassKeys
ienter insert mode (escape to exit)insertMode
rreload the current tabreloadTab
gRreload the current tab + local cachereloadTabUncached
;<*>create mark <*>setMark
''go to last scroll positionlastScrollPosition
<C-o>go to previous scroll positionpreviousScrollPosition
<C-i>go to next scroll positionnextScrollPosition
'<*>go to mark <*>goToMark
cmmute/unmute a tabmuteTab
nonereload all tabsreloadAllTabs
crreload all tabs but currentreloadAllButCurrent
zizoom page inzoomPageIn
zozoom page outzoomPageOut
z0zoom page to original sizezoomOrig
z<Enter>toggle image zoom (same as clicking the image on image-only pages)toggleImageZoom
gdalias to :chrome://downloads<CR>:chrome://downloads<CR>
gealias to :chrome://extensions<CR>:chrome://extensions<CR>
yycopy the URL of the current page to the clipboardyankDocumentUrl
yYcopy the URL of the current frame to the clipboardyankRootUrl
yacopy the URLs in the current windowyankWindowUrls
yhcopy the currently matched text from find mode (if any)yankHighlight
bsearch through bookmarks:bookmarks
popen the clipboard selectionopenPaste
Popen the clipboard selection in a new tabopenPasteTab
gjhide the download shelfhideDownloadsShelf
gfcycle through iframesnextFrame
gFgo to the root framerootFrame
gqstop the current tab from loadingcancelWebRequest
gQstop all tabs from loadingcancelAllWebRequests
gugo up one path in the URLgoUpUrl
gUgo to to the base URLgoToRootUrl
gsgo to the view-source:// page for the current Url:viewsource!
<C-b>create or toggle a bookmark for the current URLcreateBookmark
unmappedclose all browser windowsquitChrome
g-decrement the first number in the URL path (e.g www.example.com/5 => www.example.com/4)decrementURLPath
g+increment the first number in the URL pathincrementURLPath
Tab Navigation  
gtKRnavigate to the next tabnextTab
gTJEnavigate to the previous tabpreviousTab
g0g$go to the first/last tabfirstTab, lastTab
<C-S-h>ghopen the last URL in the current tab’s history in a new tabopenLastLinkInTab
<C-S-l>glopen the next URL from the current tab’s history in a new tabopenNextLinkInTab
xclose the current tabcloseTab
gxTclose the tab to the left of the current tabcloseTabLeft
gxtclose the tab to the right of the current tabcloseTabRight
gx0close all tabs to the left of the current tabcloseTabsToLeft
gx$close all tabs to the right of the current tabcloseTabsToRight
Xopen the last closed tablastClosedTab
t:tabnew:tabnew
T:tabnew <CURRENT URL>:tabnew @%
O:open <CURRENT URL>:open @%
<N>%switch to tab <N>goToTab
HSgo backgoBack
LDgo forwardgoForward
Bsearch for another active tab:buffer
<move current tab leftmoveTabLeft
>move current tab rightmoveTabRight
]]click the “next” link on the page (see nextmatchpattern above)nextMatchPattern
[[click the “back” link on the page (see previousmatchpattern above)previousMatchPattern
gppin/unpin the current tabpinTab
<C-6>toggle the focus between the last used tabslastUsedTab
Find Mode  
nnext search resultnextSearchResult
Nprevious search resultpreviousSearchResult
venter visual/caret mode (highlight current search/selection)toggleVisualMode
Venter visual line mode from caret mode/currently highlighted searchtoggleVisualLineMode
unmappedclear search mode highlightingclearSearchHighlight
Visual/Caret Mode  
<Esc>exit visual mode to caret mode/exit caret mode to normal mode 
vtoggle between visual/caret mode 
hjklmove the caret position/extend the visual selection 
ycopys the current selection 
nselect the next search result 
Nselect the previous search result 
popen highlighted text in current tab 
Popen highlighted text in new tab 
Text boxes  
<C-i>move cursor to the beginning of the linebeginningOfLine
<C-e>move cursor to the end of the lineendOfLine
<C-u>delete to the beginning of the linedeleteToBeginning
<C-o>delete to the end of the linedeleteToEnd
<C-y>delete back one worddeleteWord
<C-p>delete forward one worddeleteForwardWord
unmappeddelete back one characterdeleteChar
unmappeddelete forward one characterdeleteForwardChar
<C-h>move cursor back one wordbackwardWord
<C-l>move cursor forward one wordforwardWord
<C-f>move cursor forward one letterforwardChar
<C-b>move cursor back one letterbackwardChar
<C-j>move cursor forward one lineforwardLine
<C-k>move cursor back one linebackwardLine
unmappedselect input text (equivalent to <C-a>)selectAll
unmappededit with Vim in a terminal (need the cvim_server.py script running for this to work and the VIM_COMMAND set inside that script)editWithVim

命令模式

命令描述
:tabnew (autocomplete)open a new tab with the typed/completed search
:new (autocomplete)open a new window with the typed/completed search
:open (autocomplete)open the typed/completed URL/google search
:history (autocomplete)search through browser history
:bookmarks (autocomplete)search through bookmarks
:bookmarks /<folder> (autocomplete)browse bookmarks by folder/open all bookmarks from folder
:set (autocomplete)temporarily change a cVim setting
:chrome:// (autocomplete)open a chrome:// URL
:tabhistory (autocomplete)browse the different history states of the current tab
:command <NAME> <ACTION>aliases :<NAME> to :<ACTION>
:quitclose the current tab
:qallclose the current window
:restore (autocomplete)restore a previously closed tab (newer versions of Chrome only)
:tabattach (autocomplete)move the current tab to another open window
:tabdetachmove the current tab to a new window
:file (autocomplete)open a local file
:source (autocomplete)load a cVimrc file into memory (this will overwrite the settings in the options page if the localconfig setting had been set previously
:duplicateduplicate the current tab
:settingsopen the settings page
:nohlsearchclear the highlighted text from the last search
:executeexecute a sequence of keys (Useful for mappings. For example, “map j :execute 2j”)
:buffer (autocomplete)change to a different tab
:mksessioncreate a new session from the current tabs in the active window
:delsession (autocomplete)delete a saved session
:session (autocomplete)open the tabs from a saved session in a new window
:scriptrun JavaScript on the current page
:togglepintoggle the pin state of the current tab
:pintabpin the current tab
:unpintabunpin the current tab

提示

您可以在“打开”命令中使用@%来指定当前URL。 例如,:open @%实际上将刷新当前页面。

在命令前添加数字以重复该命令N次

在命令/查找模式下使用向上/向下箭头浏览先前执行的命令/搜索-您还可以使用此箭头搜索以特定字母组合开头的先前执行的命令(例如,在命令栏中输入ta 按向上箭头将搜索命令历史记录以ta开头的所有匹配项

发表评论