Home

Awesome

Like cVim? Consider donating! https://www.paypal.me/1995eaton

What is cVim?

Vim for Google Chrome. I hate using the mouse, especially after learning Vim. With my desktop (Linux), I have a lot of key bindings that make doing things easier: I open Chrome with Alt+w, I close a window with Alt+Shift+d, I open a terminal with Alt+t. This is harder to do with Chrome because it has no section for customizing keyboard shortcuts, and it is still necessary to use the mouse to do things like click links. cVim aims to eliminate this problem as best as the Chrome extensions API will allow it to.

Where can I get cVim?

Why is this different than Vimium, ViChrome, or Vrome?

These extensions do a wonderful job of adding Vim-like keybindings to Google Chrome, but they lack many of the features that Firefox Addon, Pentadactyl, have.

cVim Help

cVimrc

settingtypedescriptiondefault
searchlimitintegerset the amount of results displayed in the command bar25
scrollstepintegerset the amount of pixels scrolled when using the scrollUp and scrollDown commands70
timeoutlenintegerThe amount of time to wait for a <Leader> mapping in milliseconds1000
fullpagescrollpercentintegerset the percent of the page to be scrolled by when using the scrollFullPageUp and scrollFullPageDown commands0
typelinkhintsdelayintegerthe amount of time (in milliseconds) to wait before taking input after opening a link hint with typelinkhints and numerichints enabled300
scrolldurationintegerthe duration of smooth scrolling500
vimportintegerset the port to be used with the editWithVim insert mode command8001
zoomfactorinteger / doublethe step size when zooming the page in/out0.1
scalehintsbooleananimate link hints as they appearfalse
hudbooleanshow the heads-up-displaytrue
regexpbooleanuse regexp in find modetrue
ignorecasebooleanignore search case in find modetrue
linkanimationsbooleanshow fade effect when link hints open and closefalse
numerichintsbooleanuse numbers for link hints instead of a set of charactersfalse
dimhintcharactersbooleandim letter matches in hint characters rather than remove them from the hinttrue
defaultnewtabpagebooleanuse the default chrome://newtab page instead of a blank pagefalse
cncpcompletionbooleanuse <C-n> and <C-p> to cycle through completion results (requires you to set the nextCompletionResult keybinding in the chrome://extensions page (bottom right)false
smartcasebooleancase-insensitive find mode searches except when input contains a capital lettertrue
incsearchbooleanbegin auto-highlighting find mode matches when input length is greater thant two characterstrue
typelinkhintsboolean(numerichints required) type text in the link to narrow down numeric hintsfalse
autohidecursorbooleanhide the mouse cursor when scrolling (useful for Linux, which doesn't auto-hide the cursor on keydown)false
autofocusbooleanallows websites to automatically focus an input box when they are first loadedtrue
insertmappingsbooleanuse insert mappings to navigate the cursor in text boxes (see bindings below)true
smoothscrollbooleanuse smooth scrollingfalse
autoupdategistbooleanif a GitHub Gist is used to sync settings, pull updates every hour (and when Chrome restarts)false
nativelinkorderbooleanOpen new tabs like Chrome does rather than next to the currently opened tabfalse
showtabindicesbooleanDisplay the tab index in the tab's titlefalse
sortlinkhintsbooleanSort link hint lettering by the link's distance from the top-left corner of the pagefalse
localconfigbooleanRead the cVimrc config from configpath (when this is set, you connot save from cVim's options pagefalse
completeonopenbooleanAutomatically show a list of command completions when the command bar is openedfalse
configpathstringRead the cVimrc from this local file when configpath is set""
changelogbooleanAuto open the changelog when cVim is updatedtrue
completionenginesarray of stringsuse only the specified search engines["google", "duckduckgo", "wikipedia", "amazon"]
blacklistsarray of stringsdisable cVim on the sites matching one of the patterns[]
mapleaderstringThe default <Leader> key\
defaultenginestringset the default search engine"google"
localestringset the locale of the site being completed/searched on (see example configuration below)""
homedirectorystringthe directory to replace ~ when using the file command""
qmark <alphanumeric charcter>stringadd a persistent QuickMark (e.g. let qmark a = ["http://google.com", "http://reddit.com"])none
previousmatchpatternstring (regexp)the pattern looked for when navigating a page's back button((?!last)(prev(ious)?|newer|back|«|less|<|‹| )+)
nextmatchpatternstring (regexp)the pattern looked for when navigation a page's next button((?!first)(next|older|more|>|›|»|forward| )+)
hintcharactersstring (alphanumeric)set the default characters to be used in link hint mode"asdfgqwertzxcvb"
barpositionstring ["top", "bottom"]set the default position of the command bar"top"
langmapstringset a list of characters to be remapped (see vims langmap)""

Example configuration

" 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 `gna` 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

Blacklists

Site-specific Configuration

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

Running commands when a page loads

" 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
}

Mappings

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

Tabs

:open! google<CR> " This is the same as :tabnew google<CR>

:open google!<CR> " This is another way of writing the above
                  " (these flags can can be added to either
                  " the base command or the end of the final command)

:open& google<CR> " This will open Google in a new inactive tab

:open$ google<CR> " This will open Google in a new window

:open&* google<CR> " The will open Google in a new inactive, pinned tab

:tabnew google&*<CR> " Once again, this will do the same thing as the above command

:open google&*<CR> " Again, same as above

:open google!& " Here, the & flag will cancel out the ! flag,
               " opening Google in a new inactive tab

" More examples
:bookmarks my_bookmark.com&  " inactive,new tab
:bookmarks&* my_bookmark.com " inactive,pinned,new tab
:bookmarks! my_bookmark.com  " new tab
:bookmarks$ my_bookmark.com  " new window
:bookmarks my_bookmark.com   " same tab

Code blocks

" 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>

Completion Engines

let completionengines = ['google', 'google-image', 'youtube'] " Show only these engines in the command bar

Keybindings

MovementMapping name
j, sscroll downscrollDown
k, wscroll upscrollUp
hscroll leftscrollLeft
lscroll rightscrollRight
dscroll half-page downscrollPageDown
unmappedscroll full-page downscrollFullPageDown
u, escroll half-page upscrollPageUp
unmappedscroll full-page upscrollFullPageUp
ggscroll to the top of the pagescrollToTop
Gscroll to the bottom of the pagescrollToBottom
0scroll to the left of the pagescrollToLeft
$scroll to the right of the pagescrollToRight
#reset the scroll focus to the main pageresetScrollFocus
gigo to first input boxgoToInput
gIgo to the last focused input box by 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
fopen link in current tabcreateHint
Fopen link in new tabcreateTabbedHint
unmappedopen link in new tab (active)createActiveTabbedHint
Wopen link in new windowcreateHintWindow
Arepeat last hint commandopenLastHint
qtrigger a hover event (mouseover + mouseenter)createHoverHint
Qtrigger a unhover event (mouseout + mouseleave)createUnhoverHint
mfopen multiple linkscreateMultiHint
unmappededit text with external editorcreateEditHint
unmappedcall a code block with the link as the first argumentcreateScriptHint(<FUNCTION_NAME>)
unmappedopens images in a new tabfullImageHint
mrreverse image search multiple linksmultiReverseImage
myyank multiple links (open the list of links with P)multiYankUrl
gycopy URL from link to clipboardyankUrl
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
gt, K, Rnavigate to the next tabnextTab
gT, J, Enavigate to the previous tabpreviousTab
g0, g$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
H, Sgo backgoBack
L, Dgo 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
h, j, k, lmove 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

Command Mode

CommandDescription
: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<CR>")
: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

Tips

Contributing

Nice that you want to spend some time improving this extension. Solving issues is always appreciated. If you're going to add a feature, it would be best to submit an issue. You'll get feedback whether it will likely be merged.

  1. Run npm install in the repository's root folder
  2. Run make
  3. Navigate to chrome://extensions
  4. Toggle into Developer Mode
  5. Click on "Load Unpacked Extension..."
  6. Select the cVim directory.