Get it

August 25, 2018 ยท View on GitHub

sVim

sVim is a Safari extension with shortcuts similar to Vim. The functionality of sVim will mostly follow the Chrome extension cVim.

Get it

  • Download the latest release
  • Releases and release notes are all uploaded to Github on the releases page
  • The extension will update via Safari Extension Updates

Help

Shortcuts

Keyboard CommandDescriptionMapping Name
Movement
"j"scroll downscrollDown
"k"scroll upscrollUp
"h"scroll leftscrollLeft
"l"scroll rightscrollRight
"d"scroll half-page downscrollPageDown
"e", "u"scroll half-page upscrollPageUp
"shift+d"scroll full-page downscrollFullPageDown
"shift+e"scroll full-page upscrollFullPageUp
"shift+g"scroll to bottom of the pagescrollToBottom
"g g"scroll to top of the pagescrollToTop
"0"scroll to the left of the pagescrollToLeft
"$"scroll to the right of the pagescrollToRight
"g i"go to the first input boxgoToInput
"g n"find a "next page" link and navigate to itgotoNextPage
"g p"find a "previous page" link and navigate to itgotoPrevPage
Miscellaneous
"r"reload the current tabreloadTab
"z i"zoom page inzoomPageIn
"z o"zoom page outzoomPageOut
"z 0"zoom page to original sizezoomOrig
"g r"toggle Safari reader if possibletoggleReader
"g v"show sVimrc pageshowsVimrc
"g ?"open help page in new tabhelp
Tab Navigation
"g t", "shift+k"navigate to the next tabnextTab
"g shift+t", "shift+j"navigate to the previous tabpreviousTab
"g 0"go to the first tabfirstTab
"g $"go to the last tablastTab
"g l"go to the last active tab that's still openlastActiveTab
"x"close the current tabquit
"g x shift+t"close the tab to the left of the current tabcloseTabLeft
"g x t"close the tab to the right of the current tabcloseTabRight
"g x 0"close all tabs to the left of the current tabcloseTabsToLeft
"g x $"close all tabs to the right of the current tabcloseTabsToRight
"shift+x"open the last closed tablastClosedTab
"ctrl+shift+x"open the last closed tab in backgroundlastClosedTabBackground
"t"open new tabnewTab
"shift+h"go back in historygoBack
"shift+l"go forward in historygoForward
"shift+,"move current tab leftmoveTabLeft
"shift+."move current tab rightmoveTabRight
"g u"navigate to parent directoryparentDirectory
"g shift+u"navigate to top directorytopDirectory
"g d"navigate to parent domainparentDomain
"g h"navigate to home pagehomePage
Window Navigation
"w"open new windownewWindow
"g w"navigate to the next windownextWindow
"g shift+w"navigate to the previous windowpreviousWindow
Modes
"escape", "ctrl+["enter normal modenormalMode
"i"enter insert modeinsertMode
Link Hints
"f"open link in current tabcreateHint
"shift+f"open link in new background tabcreateTabbedHint
"ctrl+shift+f"open link in new foreground tabcreateForegroundHint
Clipboard
"y y"copy current URL to clipboardyankDocumentUrl

sVimrc

  • The sVimrc page is where you can customize sVim settings and css.
  • You can access the page by pressing g v or via the extension settings in Safari.
  • The sVimrc and sVimcss files can be synced via gist.
    • The gist id is found at the end of the url when viewing the gist.
    • Note it does not matter the name of your gist or the file, sVim will just grab the first file from the gist id supplied. I use sVim.rc and sVim.css.
  • For simplicity, strings in sVimrc should be wrapped in ".
  • Save the sVimrc page with command+s.
  • Goto or switch between sVimrc and sVimcss with ctrl+w.

sVimrc Commands

  • set
    • Used for boolean settings.
    • Prepend no to setting name to unset.
    • Set smooth scroll with set smoothscroll and unset with set nosmoothscroll.
  • let
    • Used to set non-boolean settings.
    • These settings can be of type integer, string or array.
    • Set new tab url like let newtaburl = "http://google.com".
    • Set scroll step like let scrollstep = 100.
    • Set black lists like let blacklists = ["*://example.com/stuff/*", "*://mail.google.com/*"].
  • map
    • Used to set/overwrite shortcuts.
    • sVim uses Mousetrap for shortcuts and keyboard commands should follow it's format.
    • You can use leader with <Leader> in the keyboard command.
    • Set the down arrow key to scroll down with map "down" scrollDown.
    • Set the leader key + the J key to scroll down with map "<Leader> j" scrollFullPageDown.
  • unmap
    • Used to remove a shortcut.
    • Remove j shortcut with unmap "j".
  • unmapAll
    • Used to remove all current shortcuts with unmapAll.
  • "
    • Used to add comments to sVimrc.
    • Comment by adding " to the beginning of the line (inline not supported).
    • Add comment like " This is a comment.

sVimrc Settings

Setting NameDescriptionTypeDefault
preventdefaultescprevent escape from exiting full screen, if unset then only prevent when not in normal modebooleantrue
smoothscrolluse smooth scrollingbooleantrue
fullpagescrollpercentpercent of the page to scroll by when using scrollFullPageUp and scrollFullPageDowninteger85
lastactivetablimitnumber of last active tabs to rememberinteger25
lastclosedtablimitnumber of closed tabs to rememberinteger25
scrolldurationduration of smooth scrollinginteger30
scrollstepamount of pixels scrolled when using scrollUp and scrollDowninteger60
zoomsteppercent to zoom when using zoomPageIn and zoomPageOutinteger10
hintcharacterscharacters to be used in link hint modestring"asdfgqwertzxcvb"
homeurlurl to use as home pagestring"topsites://"
mapleader keystring""
newtaburlurl to use as the default new tab urlstring"topsites://"
blacklistsdisable sVim on the sites matching one of the patternsarray[]
nextpagetextpatternsa list of regex patterns used to find the "next page" link on the pagearray["Next"]
prevpagetextpatternsa list of regex patterns used to find the "prev page" link on the pagearray["Previous"]

sVimrc Example

" Settings
set nosmoothscroll
let fullpagescrollpercent = 100
let lastactivetablimit = 50;
let lastclosedtablimit = 50;
let scrollduration = 25
let scrollstep = 65
let zoomstep = 15
let hintcharacters = "1234567890";
let homeurl = "http://google.com";
let mapleader = ","
let newtaburl = "http://google.com"
let blacklists = ["*://example.com/stuff/*", "*://mail.google.com/*"]
let nextpagetextpatterns = ["Next"]
let prevpagetextpatterns = ["Prev(ious)?"]

" Shortcuts
map "q" nextTab
map "shift+q" previousTab
map "<Leader> h" closeTabLeft
map "<Leader> l" closeTabRight
map "down" scrollDown
map "up" scrollUp
map "left" scrollLeft
map "right" scrollRight
map "space" scrollFullPageDown