"2.3.1 (created: 2010/04/07 18:25:13) " delete any previously defined autocommands in this context autocmd! " `mapleader` setting/option is removed! map , set urlseparator='\|' " set guioptions+=N set gui=nomenu,tabs,navigation " Currently broken. " set tabnumbers set! browser.dom.window.dump.enabled=true set! devtools.errorconsole.enabled=true " do not activate middle- or ctrl-clicked links set activate-=links " search shortcuts (without completion) command! -nargs=* gg open google map s :gg map S :tab gg " bypass ctrl-tab (ref: http://code.google.com/p/dactyl/issues/detail?id=171) " NOTE: only required for Pentadactyl " nmap " nmap nnoremap nnoremap " command to clear history " command! clearhist sanitize commandline " Esc: abort request noremap noremap :tab:help " prev/next for german keyboard layout nnoremap ö [[ nnoremap ä ]] " next/prev as single word is rather weak! " group prevnext au LocationChange .* set previouspattern='^voriges Angebot$',^<$,^<(?!<),[^<]<$,'^(prev|previous|früher|zurück|Vorherige)$','(vorige Seite|next page)',^(<<|«|‹)$,^«,«$,^‹,'\b(prev|previous|zurück)\b' au LocationChange .* set nextpattern='^nächstes Angebot$',^>$,^>(?!>),[^>]>$,'^(next|more|weiter|später)$','(nächste Seite|next page)',^(>>|»|›)$,^»,»$,›$,'\b(next|more|weiter|vor(wärts)?)\b' au LocationChange www.xing.com set previouspattern=^Zurück$ nextpattern=^Weiter$ " TODO test au LocationChange www.xda-developers.com set previouspattern='^newer entries$' nextpattern='^older entries$' " heise.de: start page and comments au LocationChange www.heise.de set previouspattern='^Neuere$',^<<$ nextpattern='^Ältere$',^>>$ " forum.xda-developers.com au LocationChange ://[^]+/showthread\.php\? set previouspattern='^<$' au LocationChange ://[^]+/showthread\.php\? set nextpattern='^>$' " group default set popups=tab,resized " A builtin bit.ly shortener. " Based on http://github.com/scy/dotscy/commit/4526f23a09b2ae51fb7f4b1e2ed3aec84f318fa5 javascript < gy :js shortenURLBitLy(buffer.URL) " Toggle hosts / urls: handle special cases, and fallback to appending or " removing '.localdomain' suffix. " This is meant to easily switch between local/development and live " environment. javascript < blueyed: let uri = buffer.uri.clone(); uri.host = whatever; uri.spec // first check custom maps of hostnames to toggle let cb_handle_q_arg = function(url, lhs, rhs) { // return url.replace(lhs, rhs).replace(/[&?](?!q=[&?])*/, ''); let qd = parseQueryString(); return url.replace(lhs, rhs).replace(/[&?].*/, '?q=' + qd["q"]); } let customtoggle = { 'de.wikipedia.org': 'en.wikipedia.org', 'en.wikipedia.org': 'de.wikipedia.org', // Toggle between DuckDuckGo and Googgle. // map 'https://duckduckgo.com/?q=foo+bar' // to 'https://www.google.com/search?q=foo+bar' '://duckduckgo.com/': {'rhs': '://www.google.com/search', 'cb': cb_handle_q_arg}, '://www.google.com/search': {'rhs': '://duckduckgo.com/', 'cb': cb_handle_q_arg}, '://www.google.de/search': {'rhs': '://duckduckgo.com/', 'cb': cb_handle_q_arg}, } let curhost = content.location.host; let cururl = buffer.URL; console.log(curhost); for( var lhs in customtoggle ) { let rhs = customtoggle[lhs]; if( cururl.indexOf(lhs) != -1 ) { if( typeof(rhs) == 'string' ) { return String.replace(cururl, lhs, rhs); } return rhs.cb(cururl, lhs, rhs.rhs); } } // Fallthrough: prepend/remove suffix. let suffix = '.localdomain'; if( curhost.indexOf(suffix, curhost.length - suffix.length) !== -1 ) { return String.replace(cururl, suffix, ''); } // Append/inject suffix. return String.replace(cururl, /(\.\w{2,4})([\/:])/, "$1"+suffix+"$2"); } EOF map gz :js liberator.open(toggleHosts()) " Firefox Sync: connect+sync on startup, sync on exit (does not appear to work) " NOTE: gets triggered when opening a new window, too. With some Sync UI again in the status bar, this is not necessary anymore. "autocmd VimperatorEnter .* emenu Tools.Sync.Connect "autocmd VimperatorEnter .* emenu Tools.Sync.Sync Now "autocmd VimperatorLeavePre .* emenu Tools.Sync.Sync Now " Setup colors(cheme) " colorscheme solarized-light colorscheme solarized " Pimp colors/layout hi -append Hint font-size:10px !important;font-weight:normal !important;background:#fff !important;border:1px solid red !important;color:#000 !important;font-family:"DejaVu Sans Mono", monospace !important; padding:1px 3px !important; " hi -append StatusLine background-color:#ddd !important; color:#000 !important; border-bottom:1px solid #666 !important; border-top:1px solid #666 !important " " " Make the "Find hit TOP, continuing at BOTTOM" more prominent " hi StatusWarningMsg -append background-color:blue ! important; color:white ! important; " " " TODO: see TabVisited extension: https://bugzilla.mozilla.org/show_bug.cgi?id=487242 " style -name blueyedchrome chrome://* < var feedPanel = document.createElement("statusbarpanel"); feedPanel.setAttribute("id", "feed-panel-clone"); feedPanel.appendChild(feedButton); feedPanel.firstChild.setAttribute("style", "padding: 0; max-height: 16px;"); document.getElementById("status-bar") .appendChild(feedPanel); // .insertBefore(feedPanel, document.getElementById("security-button")); } })(); EOF " reddit tips (via http://www.reddit.com/r/vim/comments/crs9u/some_vimperator_tips_for_redditors/) " open current page with reddit toolbar (allows submitting) nmap e :js liberator.open("http://reddit.com/submit?url=" + encodeURIComponent(buffer.URL)) " add bookmark for subreddits (":o r") "bma -k=r http://reddit.com/r/%s/ " focus content frame (workaround for FF4?!) " XXX: content.wrappedJSObject.frames["inner_toolbar"] ... "autocmd PageLoad ^http://www.reddit.com/tb/.* js content.window.frames[1].window.frames[1].focus() " Does not work for pages that use Javascript to focus an input box, e.g. " Groupon. set focuscontent " command to replace all image links with the actual image (most useful with post-a-picture threads) " based on some snippet from reddit, but adopted for Vimperator; add allFrames and maxHeight handling command! inlineimages js (function($) {orig$=$; $.each(buffer.allFrames, function(){win=this.wrappedJSObject; $=function(sel){return orig$(sel, win.document)} ; win.document.ondragstart=function(){return false};dst=function(e){return (p=Math.pow)(p(e.clientX-(rc=e.target.getBoundingClientRect()).left,2)+p(e.clientY-rc.top,2),.5)};$("[href~=imgur]").not($(t="[href$=jpeg],[href$=gif],[href$=png],[href$=jpg]")).each(function(){this.href+='.jpg'});void($(t).not(".EGraw").attr({'class':'EGraw',target:'blank'}).each(function(){$(this).append($('').toggle(function(e){$(this).html(' [-]').next().show();return false},function(e){$(this).html(' [+]').next().hide();return false}).click()).append($('').attr({src:this.href,style:'display:block;max-width:500px;max-height:500px',title:'Drag to resize'}).mousedown(function(e){(t=this.wrappedJSObject).iw=t.width;t.d=dst(e);t.dr=false;t.style.maxHeight="none";e.preventDefault();}).mousemove(function(e){if((t=this.wrappedJSObject).d){t.style.maxWidth=t.style.width=((dst(e))*t.iw/t.d)+"px";t.dr=true}}).mouseout(f=function(e){(t=this.wrappedJSObject).d=false;if(t.dr)return false}).click(f))}))})})(content.wrappedJSObject.$ || $); " search leo.org in a new tab map l :to http://dict.leo.org/ende?lp=ende&search= " Open current location via Coral CDN " String.replace is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=633830 map gp :js liberator.open( String.replace(buffer.URL, /(\.\w{2,4})\//, "$1.nyud.net/") ) " NoScript popup map n :noscript popup " Toggle pocket sidebar nmap p :emenu View.Sidebar.Pocket " Quickmarks (for `go` and `gn`) silent qmark 0 hahler.de silent qmark a https://www.google.com/contacts silent qmark c https://www.google.com/calendar silent qmark f https://facebook.com silent qmark g https://groups.google.com/forum/#!myforums silent qmark h https://heise.de silent qmark m https://mail.google.com/mail silent qmark n https://www.google.de/reader/view | www.reddit.com | https://twitter.com silent qmark p https://www.producteev.com/dashboard.php silent qmark r https://reddit.com silent qmark t https://twitter.com silent qmark z https://github.com/notifications " Use buffer.URL for yanking (encoded spaces). " (not required for Pentadactyl, see http://code.google.com/p/vimperator-labs/issues/detail?id=797). js <, )"' " " NOTE: no support for "" and " with Vimperator: http://code.google.com/p/vimperator-labs/issues/detail?id=875 " " js my_editor='gvim' + ' -f -c "set ft={0} | call cursor(, )"' " js my_editor='gvim' + ' -f -c "set ft={0}"' " autocmd -js LocationChange .* options.editor=my_editor.replace('{0}', 'html spell') " autocmd -js LocationChange (www\.reddit\.com|github\.com|stackoverflow\.com)/ options.editor=my_editor.replace('{0}', 'markdown spell') " autocmd -js LocationChange ^https?://mail\\..* options.editor=my_editor.replace('{0}', 'mail spell') " autocmd -js LocationChange ^https?://[^/]+/phpmyadmin/ options.editor=my_editor.replace('{0}', 'html') " autocmd -js LocationChange ^https?://.*trac.*/wiki/ options.editor=my_editor.replace('{0}', 'tracwiki') " " group default " }}}2 " Initially done via autocmd (see above), then rewritten based on [1] and adopted for Vimperator. " 1: http://ingo-karkat.de/blog/2012/05/22/Pentadactyl%20set%20filetype%20in%20external%20Vim%20editor%20based%20on%20URL.html set editor='vim-in-term' javascript <"], "Launch the external editor.", editExternallyWithOptions); // Alternative mapping in case is taken, e.g. in reddit/stackoverflow comments. mappings.addUserMap([modes.INSERT], [""], "Launch the external editor.", editExternallyWithOptions); EOF " }}}1 " Bypassing keys. {{{1 javascript < zz :centerselect "nnoremap zz :centerselect "border: 5px solid orange;" "nnoremap n n:norm zz "nnoremap N N:norm zz nnoremap zH 10h nnoremap zL 10l nnoremap j 5j nnoremap k 5k nnoremap l 5l nnoremap h 5h " Use Ctrl-d/u instead?! nnoremap J 20j nnoremap K 20k nnoremap zt :topselect nnoremap zb :bottomselect nnoremap zc :removeselect nnoremap h H nnoremap l L " tab-options plugin: "set tabclose=opener,previous,left,right " Focus largest frame. This replaces the auto-focus-frame.js plugin. Props @John-Galt! au PageLoad .* -js function area(w) w.innerWidth * w.innerHeight; buffer.allFrames(doc.defaultView.top).reduce(function (w, acc) area(w) > area(acc) ? w : acc).focus() nnoremap c :js buffer.openContextMenu() " Yank document.title. nnoremap yt :js util.copyToClipboard(content.document.title, true) " Yank 'Issue #X: title (URL)' from Github issue page. javascript <yl :js myCopyGithubIssueTitle(buffer) " remap for smooth scrolling map j map k " Edit ~/.vimperatorrc in global gvim server instance. map ec :silent !vim-in-term ~/.dotfiles/vimperatorrc & " Toggle colorscheme. au ColorScheme .* -javascript curtheme = args.name map sc :execute "colorscheme " + ((typeof(curtheme) !== 'undefined' && curtheme == "solarized_light") ? "solarized_dark" : "solarized_light" ) source! ~/.vimperatorrc.local " vim: set ft=pentadactyl.vim fdm=marker: