chromium-vim Vim bindings for Google Chrome.开源项目

我要开发同款
匿名用户2021年11月23日
38阅读
开发技术JavaScript
所属分类插件和扩展、Chrome插件/扩展
授权协议MIT License

作品详情

LikecVim?Considerdonating!https://www.paypal.me/1995eatonWhatiscVim?

VimforGoogleChrome.Ihateusingthemouse,especiallyafterlearningVim.Withmydesktop(Linux),Ihavealotofkeybindingsthatmakedoingthingseasier:IopenChromewithAlt+w,IcloseawindowwithAlt+Shift+d,IopenaterminalwithAlt+t.ThisishardertodowithChromebecauseithasnosectionforcustomizingkeyboardshortcuts,anditisstillnecessarytousethemousetodothingslikeclicklinks.cVimaimstoeliminatethisproblemasbestastheChromeextensionsAPIwillallowitto.

WherecanIgetcVim?Therearetwoways:YoucaninstallitthroughtheChromewebstoreYoucandownloadthe.zipfilehereandenablecVimbygoingtothechrome://extensionsURLandcheckingdevelopermode,thenpointingChrometotheunzippedfolderviatheLoadunpackedextensions...button.WhyisthisdifferentthanVimium,ViChrome,orVrome?

TheseextensionsdoawonderfuljobofaddingVim-likekeybindingstoGoogleChrome,buttheylackmanyofthefeaturesthatFirefoxAddon,Pentadactyl,have.

WhatfeaturesdoescVimaddtoChrome?Google/IMDB/Wikipedia/Amazon/Duckduckgo/Yahoo/BingsearchcompletionSupportforcustomsearchenginesHistoryandBookmarksearch/completionwithbookmarkfoldersupportCaret/VisualmodeEfficientlinkhints(withsupportforcustommappings)SupportforcustomkeyboardmappingsRegexpagesearchwithhighlightingCommandbarwithtab-completionSmoothscrollingcVimHelpcVimrcBooleancVimrcsettingsareenabledwiththecommand'set'+<SETTING_NAME>anddisabledwiththecommand'set'+no<SETTING_NAME>(forexample,setregexpandsetnoregexp)BooleancVimrcsettingscanbeinversedbyadding"!"totheendOthersettingsaredefinedwith=usedasaseparatorandareprefixedbylet(forexample,lethintcharacters="abc")settingtypedescriptiondefaultsearchlimitintegersettheamountofresultsdisplayedinthecommandbar25scrollstepintegersettheamountofpixelsscrolledwhenusingthescrollUpandscrollDowncommands70timeoutlenintegerTheamountoftimetowaitfora<Leader>mappinginmilliseconds1000fullpagescrollpercentintegersetthepercentofthepagetobescrolledbywhenusingthescrollFullPageUpandscrollFullPageDowncommands0typelinkhintsdelayintegertheamountoftime(inmilliseconds)towaitbeforetakinginputafteropeningalinkhintwithtypelinkhintsandnumerichintsenabled300scrolldurationintegerthedurationofsmoothscrolling500vimportintegersettheporttobeusedwiththeeditWithViminsertmodecommand8001zoomfactorinteger/doublethestepsizewhenzoomingthepagein/out0.1scalehintsbooleananimatelinkhintsastheyappearfalsehudbooleanshowtheheads-up-displaytrueregexpbooleanuseregexpinfindmodetrueignorecasebooleanignoresearchcaseinfindmodetruelinkanimationsbooleanshowfadeeffectwhenlinkhintsopenandclosefalsenumerichintsbooleanusenumbersforlinkhintsinsteadofasetofcharactersfalsedimhintcharactersbooleandimlettermatchesinhintcharactersratherthanremovethemfromthehinttruedefaultnewtabpagebooleanusethedefaultchrome://newtabpageinsteadofablankpagefalsecncpcompletionbooleanuse<C-n>and<C-p>tocyclethroughcompletionresults(requiresyoutosetthenextCompletionResultkeybindinginthechrome://extensionspage(bottomright)falsesmartcasebooleancase-insensitivefindmodesearchesexceptwheninputcontainsacapitallettertrueincsearchbooleanbeginauto-highlightingfindmodematcheswheninputlengthisgreaterthanttwocharacterstruetypelinkhintsboolean(numerichintsrequired)typetextinthelinktonarrowdownnumerichintsfalseautohidecursorbooleanhidethemousecursorwhenscrolling(usefulforLinux,whichdoesn'tauto-hidethecursoronkeydown)falseautofocusbooleanallowswebsitestoautomaticallyfocusaninputboxwhentheyarefirstloadedtrueinsertmappingsbooleanuseinsertmappingstonavigatethecursorintextboxes(seebindingsbelow)truesmoothscrollbooleanusesmoothscrollingfalseautoupdategistbooleanifaGitHubGistisusedtosyncsettings,pullupdateseveryhour(andwhenChromerestarts)falsenativelinkorderbooleanOpennewtabslikeChromedoesratherthannexttothecurrentlyopenedtabfalseshowtabindicesbooleanDisplaythetabindexinthetab'stitlefalsesortlinkhintsbooleanSortlinkhintletteringbythelink'sdistancefromthetop-leftcornerofthepagefalselocalconfigbooleanReadthecVimrcconfigfromconfigpath(whenthisisset,youconnotsavefromcVim'soptionspagefalsecompleteonopenbooleanAutomaticallyshowalistofcommandcompletionswhenthecommandbarisopenedfalseconfigpathstringReadthecVimrcfromthislocalfilewhenconfigpathisset""changelogbooleanAutoopenthechangelogwhencVimisupdatedtruecompletionenginesarrayofstringsuseonlythespecifiedsearchengines["google","duckduckgo","wikipedia","amazon"]blacklistsarrayofstringsdisablecVimonthesitesmatchingoneofthepatterns[]mapleaderstringThedefault<Leader>key\defaultenginestringsetthedefaultsearchengine"google"localestringsetthelocaleofthesitebeingcompleted/searchedon(seeexampleconfigurationbelow)""homedirectorystringthedirectorytoreplace~whenusingthefilecommand""qmark<alphanumericcharcter>stringaddapersistentQuickMark(e.g.letqmarka=["https://google.com","https://reddit.com"])nonepreviousmatchpatternstring(regexp)thepatternlookedforwhennavigatingapage'sbackbutton((?!last)(prev(ious)?|newer|back|«|less|<|‹|)+)nextmatchpatternstring(regexp)thepatternlookedforwhennavigationapage'snextbutton((?!first)(next|older|more|>|›|»|forward|)+)hintcharactersstring(alphanumeric)setthedefaultcharacterstobeusedinlinkhintmode"asdfgqwertzxcvb"barpositionstring["top","bottom"]setthedefaultpositionofthecommandbar"top"langmapstringsetalistofcharacterstoberemapped(seevimslangmap)""Exampleconfiguration"Settingssetnohudsetnosmoothscrollsetnoautofocus"Theoppositeofautofocus;thissettingstops"sitesfromfocusingonaninputboxwhentheyloadsettypelinkhintsletsearchlimit=30letscrollstep=70letbarposition="bottom"letlocale="uk""Currentchoicesare'jp'and'uk'.ThisallowscVimtousesiteslikegoogle.co.uk"orgoogle.co.jptosearchratherthangoogle.com.Supportiscurrentlylimited."Letmeknowifyouneedadifferentlocaleforoneofthecompletion/searchengineslethintcharacters="abc123"letsearchenginedogpile="https://www.dogpile.com/search/web?q=%s""Ifyouleaveoutthe'%s'attheendoftheURL,"yourquerywillbeappendedtothelink."Otherwise,yourquerywillreplacethe'%s'."Thiswilldothesamethingasabove,excepttyping':tabnewwithbase'intotocommandbar"withoutanysearchparameterswillopen'https://www.dogpile.com'letsearchenginewithbase=["https://www.dogpile.com","https://www.dogpile.com/search/web?q=%s"]"alias':g'to':tabnewgoogle'commandgtabnewgoogleletcompletionengines=["google","amazon","imdb","dogpile"]letsearchaliasg="google""Createashortcutforsearchengines."Forexample,typing':tabnewgexample'"wouldactthesamewayas':tabnewgoogleexample'"Openalloftheseinatabwith`gnb`oropenoneofthesewith<N>goawhere<N>letqmarka=["https://www.reddit.com","https://www.google.com","https://twitter.com"]letblacklists=["https://mail.google.com/*","*://mail.google.com/*","@https://mail.google.com/mail/*"]"blacklistsprefixedby'@'actasawhitelistletmapleader=",""Mappingsmap<Leader>rreloadTabUncachedmap<Leader>x:restore<Space>"Thisremapsthedefault'j'mappingmapjscrollUp"Youcanuse<Space>,whichisinterpretedasa"literal""character,toenterbuffercompletionmodemapgb:buffer<Space>"Thisunmapsthedefault'k'mappingunmapk"Thisunmapsthedefault'h','j','k',and'l'mappingsunmaphjkl"Thisremapsthedefault'f'mappingtothecurrent'F'mappingmapfF"TogglethecurrentHUDdisplayvaluemap<C-h>:sethud!<CR>"Switchbetweenalphabeticalhintcharactersandnumerichintsmap<C-i>:setnumerichints!<CR>map<C-u>rootFramemap<M-h>previousTabmap<C-d>scrollPageDownmap<C-e>scrollPageUpiunmap<C-y>imap<C-m>deleteWord"Createavariablethatcanbeused/referencedinthecommandbarlet@@reddit_prog='https://www.reddit.com/r/programming'let@@top_all='top?sort=top&t=all'let@@top_day='top?sort=top&t=day'"TAbindingopens'https://www.reddit.com/r/programming/top?sort=top&t=all'inanewtabmapTA:tabnew@@reddit_prog/@@top_all<CR>mapTD:tabnew@@reddit_prog/@@top_day<CR>"UsepastebufferinmappingsmapT:tabnewwikipedia@"<CR>"Codeblocks(seebelowformoreinfo)getIP()->{{httpRequest({url:'https://api.ipify.org/?format=json',json:true},function(res){Status.setMessage('IP:'+res.ip);});}}"DisplaysyourpublicIPaddressinthestatusbarmapci:callgetIP<CR>"Scripthintsecho(link)->{{alert(link.href);}}map<C-f>createScriptHint(echo)letconfigpath='/path/to/your/.cvimrc'setlocalconfig"Updatesettingsviaalocalfile(andthe`:source`command)rather"thanthedefaultoptionspageinchrome"Aslongaslocalconfigissetinthe.cvimrcfile.cVimwillcontinuetoread"settingsfromthereBlacklistsTheblacklistssettingusesacustominplementationofChrome's@matchpatternguidelines.Seehttps://developer.chrome.com/extensions/match_patternsforadescriptionofthesyntax.Site-specificConfigurationYoucanenablecertainrcsettingsforsitesusingtheblacklistmatchpatternasdescribedabove"thiswillenabletheconfigblockbelowonthedomain'reddit.com'site'*://*.reddit.com/*'{unmapjunmapksetnumerichints}RunningcommandswhenapageloadsInasimilarfashiontothesite-specificconfigurationdescribedabove,cVimcanruncommandswhenapageisloadedwiththecallkeyword"Inthiscase,whenpageswithafileendingin'.js'areloaded,"cVimwillpinthetabandthenscrolldownsite'*://*/*.js'{call:pintabcallscrollDown}MappingsNormalmappingsaredefinedwiththefollowingstructure:map<KEY><MAPPING_NAME>Insertmappingsusethesamestructure,butusethecommand"imap"insteadof"map"Control,meta,andaltcanbeusedalso:<C-u>"Ctrl+u<M-u>"Meta+u<A-u>"Alt+uItisalsopossibletounmapdefaultbindingswithunmap<KEY>andinsertbindingswithiunmap<KEY>Tounmapalldefaultkeybindings,useunmapAll.Tounmapalldefaultinsertbindings,useiunmapAllTabsCommandsthatopenlinks(:tabnewand:open)havethreedifferentproperties!=>Openinanewtab$=>Openinanewwindow|=>Openinanincognitowindow&=>Openinanewtab(inactive/unfocused)*=>Pinthetab?=>Treatthequeryasasearch==>TreatthequeryasaURLTheuseofthesepropertiesarebestexplainedwithexamples::open!google<CR>"Thisisthesameas:tabnewgoogle<CR>:opengoogle!<CR>"Thisisanotherwayofwritingtheabove"(theseflagscancanbeaddedtoeither"thebasecommandortheendofthefinalcommand):open&google<CR>"ThiswillopenGoogleinanewinactivetab:open$google<CR>"ThiswillopenGoogleinanewwindow:open&*google<CR>"ThewillopenGoogleinanewinactive,pinnedtab:tabnewgoogle&*<CR>"Onceagain,thiswilldothesamethingastheabovecommand:opengoogle&*<CR>"Again,sameasabove:opengoogle!&"Here,the&flagwillcanceloutthe!flag,"openingGoogleinanewinactivetab"Moreexamples:bookmarksmy_bookmark.com&"inactive,newtab:bookmarks&*my_bookmark.com"inactive,pinned,newtab:bookmarks!my_bookmark.com"newtab:bookmarks$my_bookmark.com"newwindow:bookmarksmy_bookmark.com"sametabCodeblocksCodeblocksallowyoutointeractwithcVim'scontentscriptsviathecVimrc.Sincecodeblocksuseeval(...),youshouldonlyusethemifyouknowwhatyou'redoing."Tobeusedbythecodeblocksethintset_a"CreateacodeblocknamedswitchHintCharactersswitchHintCharacters->{{//WearenowinJavaScriptmode//Settingsarecontainedinanobjectnamedsettingssettings.hintset_a=!settings.hintset_a;if(settings.hintset_a){settings.hintcharacters='abc';//equivalentto"lethintcharacters='abc'"}else{settings.hintcharacters='xyz';}//Propagatethecurrentsettingstoalltabsforthe//restofthesessionPORT('syncSettings',{settings:settings});//DisplaycVim'sstatusbarfor2seconds.Status.setMessage('HintSet:'+(true?'a':'b'),2);}}"RuntheJavaScriptblockmap<Tab>:callswitchHintCharacters<CR>CompletionEnginesThesearealistofcompletionenginesthatcanbeusedinthecommandbar.Theycanbesetbyassigningtheirnamestoanarraywiththecompletionenginesvariable.google,wikipedia,youtube,imdb,amazon,google-maps,wolframalpha,google-image,ebay,webster,wictionary,urbandictionary,duckduckgo,answers,google-trends,google-finance,yahoo,bing,themoviedbExampleusage:letcompletionengines=['google','google-image','youtube']"ShowonlytheseenginesinthecommandbarKeybindingsMovementMappingnamej,sscrolldownscrollDownk,wscrollupscrollUphscrollleftscrollLeftlscrollrightscrollRightdscrollhalf-pagedownscrollPageDownunmappedscrollfull-pagedownscrollFullPageDownu,escrollhalf-pageupscrollPageUpunmappedscrollfull-pageupscrollFullPageUpggscrolltothetopofthepagescrollToTopGscrolltothebottomofthepagescrollToBottom0scrolltotheleftofthepagescrollToLeft$scrolltotherightofthepagescrollToRight#resetthescrollfocustothemainpageresetScrollFocusgigotofirstinputboxgoToInputgIgotothelastfocusedinputboxbygigoToLastInputzzcenterpagetocurrentsearchmatch(middle)centerMatchHztcenterpagetocurrentsearchmatch(top)centerMatchTzbcenterpagetocurrentsearchmatch(bottom)centerMatchBLinkHintsfopenlinkincurrenttabcreateHintFopenlinkinnewtabcreateTabbedHintunmappedopenlinkinnewtab(active)createActiveTabbedHintWopenlinkinnewwindowcreateHintWindowArepeatlasthintcommandopenLastHintqtriggerahoverevent(mouseover+mouseenter)createHoverHintQtriggeraunhoverevent(mouseout+mouseleave)createUnhoverHintmfopenmultiplelinkscreateMultiHintunmappededittextwithexternaleditorcreateEditHintunmappedcallacodeblockwiththelinkasthefirstargumentcreateScriptHint(<FUNCTION_NAME>)unmappedopensimagesinanewtabfullImageHintmrreverseimagesearchmultiplelinksmultiReverseImagemyyankmultiplelinks(openthelistoflinkswithP)multiYankUrlgycopyURLfromlinktoclipboardyankUrlgrreverseimagesearch(googleimages)reverseImage;changethelinkhintfocusQuickMarksM<*>createquickmark<*>addQuickMarkgo<*>openquickmark<*>inthecurrenttabopenQuickMarkgn<*>openquickmark<*>inanewtabopenQuickMarkTabbedgw<*>openquickmark<*>inanewwindowopenQuickMarkWindowedMiscellaneousaaliasto":tabnewgoogle":tabnewgoogle.repeatthelastcommandrepeatCommand:opencommandbaropenCommandBar/opensearchbaropenSearchBar?opensearchbar(reversesearch)openSearchBarReverseunmappedopenlinksearchbar(sameaspressing/?)openLinkSearchBarIsearchthroughbrowserhistory:history<N>g%scroll<N>percentdownthepagepercentScroll<N>unmappedpass<N>keysthroughtothecurrentpagepassKeysienterinsertmode(escapetoexit)insertModerreloadthecurrenttabreloadTabgRreloadthecurrenttab+localcachereloadTabUncached;<*>createmark<*>setMark''gotolastscrollpositionlastScrollPosition<C-o>gotopreviousscrollpositionpreviousScrollPosition<C-i>gotonextscrollpositionnextScrollPosition'<*>gotomark<*>goToMarkcmmute/unmuteatabmuteTabnonereloadalltabsreloadAllTabscrreloadalltabsbutcurrentreloadAllButCurrentzizoompageinzoomPageInzozoompageoutzoomPageOutz0zoompagetooriginalsizezoomOrigz<Enter>toggleimagezoom(sameasclickingtheimageonimage-onlypages)toggleImageZoomgdaliasto:chrome://downloads<CR>:chrome://downloads<CR>gealiasto:chrome://extensions<CR>:chrome://extensions<CR>yycopytheURLofthecurrentpagetotheclipboardyankDocumentUrlyYcopytheURLofthecurrentframetotheclipboardyankRootUrlyacopytheURLsinthecurrentwindowyankWindowUrlsyhcopythecurrentlymatchedtextfromfindmode(ifany)yankHighlightbsearchthroughbookmarks:bookmarkspopentheclipboardselectionopenPastePopentheclipboardselectioninanewtabopenPasteTabgjhidethedownloadshelfhideDownloadsShelfgfcyclethroughiframesnextFramegFgototherootframerootFramegqstopthecurrenttabfromloadingcancelWebRequestgQstopalltabsfromloadingcancelAllWebRequestsgugouponepathintheURLgoUpUrlgUgototothebaseURLgoToRootUrlgsgototheview-source://pageforthecurrentUrl:viewsource!<C-b>createortoggleabookmarkforthecurrentURLcreateBookmarkunmappedcloseallbrowserwindowsquitChromeg-decrementthefirstnumberintheURLpath(e.gwww.example.com/5=>www.example.com/4)decrementURLPathg+incrementthefirstnumberintheURLpathincrementURLPathTabNavigationgt,K,RnavigatetothenexttabnextTabgT,J,EnavigatetotheprevioustabpreviousTabg0,g$gotothefirst/lasttabfirstTab,lastTab<C-S-h>,ghopenthelastURLinthecurrenttab'shistoryinanewtabopenLastLinkInTab<C-S-l>,glopenthenextURLfromthecurrenttab'shistoryinanewtabopenNextLinkInTabxclosethecurrenttabcloseTabgxTclosethetabtotheleftofthecurrenttabcloseTabLeftgxtclosethetabtotherightofthecurrenttabcloseTabRightgx0closealltabstotheleftofthecurrenttabcloseTabsToLeftgx$closealltabstotherightofthecurrenttabcloseTabsToRightXopenthelastclosedtablastClosedTabt:tabnew:tabnewT:tabnew<CURRENTURL>:tabnew@%O:open<CURRENTURL>:open@%<N>%switchtotab<N>goToTabH,SgobackgoBackL,DgoforwardgoForwardBsearchforanotheractivetab:buffer<movecurrenttableftmoveTabLeft>movecurrenttabrightmoveTabRight]]clickthe"next"linkonthepage(seenextmatchpatternabove)nextMatchPattern[[clickthe"back"linkonthepage(seepreviousmatchpatternabove)previousMatchPatterngppin/unpinthecurrenttabpinTab<C-6>togglethefocusbetweenthelastusedtabslastUsedTabFindModennextsearchresultnextSearchResultNprevioussearchresultpreviousSearchResultventervisual/caretmode(highlightcurrentsearch/selection)toggleVisualModeVentervisuallinemodefromcaretmode/currentlyhighlightedsearchtoggleVisualLineModeunmappedclearsearchmodehighlightingclearSearchHighlightVisual/CaretMode<Esc>exitvisualmodetocaretmode/exitcaretmodetonormalmodevtogglebetweenvisual/caretmodeh,j,k,lmovethecaretposition/extendthevisualselectionycopysthecurrentselectionnselectthenextsearchresultNselecttheprevioussearchresultpopenhighlightedtextincurrenttabPopenhighlightedtextinnewtabTextboxes<C-i>movecursortothebeginningofthelinebeginningOfLine<C-e>movecursortotheendofthelineendOfLine<C-u>deletetothebeginningofthelinedeleteToBeginning<C-o>deletetotheendofthelinedeleteToEnd<C-y>deletebackoneworddeleteWord<C-p>deleteforwardoneworddeleteForwardWordunmappeddeletebackonecharacterdeleteCharunmappeddeleteforwardonecharacterdeleteForwardChar<C-h>movecursorbackonewordbackwardWord
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论