Emacs Quick Reference

Emacs Quick Reference

EmacsQuickReference Page1of4 EmacsQuick Emacs-Ring-SiteNumber27 Reference [NextSite|SkipNextSite|PreviousSite|SkipPreviousSite|ListSites| Home] ByPaulSeamons Notation ItisimportanttounderstandthenotationcommonlyusedinEmacsdocumentation.MostofthecommandsusedinEmacsconsistofamodifierkey,in conjuctionwithoneormoreotherkeys.Thefollowingarethecommonmodifierkeys: CTRL -(C)- TheCONTROLkey. META -(M)- DependingupontheterminalthisistheALTkey.YoumayalsousetheESCkeytosendMETA. ESC -(ESC)- TheESCAPEkey. SHIFT -(S)- TheSHIFTkey. InEmacsdocumentationitiscommontouseanabbreviatedsyntaxwhendescribingkeysequences.Insteadoftyping CTRL-xCTRL-c Youwouldtype C-xC-c ThiswouldrepresentholdingdowntheCONTROLkeyandpressingtheletterx,andthenholdingdowntheCONTROLkeyandpressingtheletterc. (M-C-\wouldrepresentholdingdownthetheALTkeyandCONTROLkeyandpressingthe"\"key.YoucouldalsopressandreleasetheESCAPEkey holddowntheCONTROLkeyandtypethe"\"key.) Thefollowingisatableofnotationforotherkeyboardcharacters. BACKSPC TheBACKSPACEkey. SPC TheSPACEbar. ENTER TheEnterkey. RET TheEnterkey. TAB TheTABkey. InsertMode? ThisisalargeplacewhereEmacsdiffersfromtheVieditor.InViyouareeitherinInsertModeoryouarenot.Inordertoexecutecommandsotherthan keyinsertionyouneedtobeoutofInsertionMode.ByusingCTRLtoescapethekeysequences,Emacsallowsyoutousethecommandsatanypoint inyoursession.Forexample,ifyouareinViandareinsertingtextyouwouldhavetotypethefollowingkeysequencetosaveyourfileandreturnto InsertMode: ESC:wi InEmacs(whichisessentiallyalwaysin"InsertMode")youwouldtypethefollowing: C-xC-s Whenviewedfromtheinsertionmodeviewpoint,Vidoesn'treallysaveanykeystrokesoverEmacsasiscommonlyclaimedbyreligiousViadvocates. (Itactuallyrequiresmoreinmostcases-thedebateisreallywhetheryou'reinInsertModemorethanyouareinCommandMode.) Whatisreallyhappeningonthebackend Emacsisreallyabunchoflisproutinesprogrammedtooperateonthetextinthebuffers.Thesecomplexroutinesareaccessedviakeybindingsonthe frontend.Forexample,whenyoutypean"s"youarereallytellingEmacstorunthe"self-insert-command"ontheletter"s"whichinsertstheletter"s"at thecurrentPointofInsertion(POI).ThesebackendcommandscanbeaccessedbytypingM-xandthenthecommand.Forexample,youopenafile withthekeybinding"C-xC-f".Youcanbeginthesameoperationbytyping"M-xfind-file". KeyboardShortcuts-(KeyBindings) Key Binding Backend Function Whatitdoes QuitingThings M-xsave-buffers- .ExitsoutofEmacs.Ifyouhaveopenbuffersthathavebeenmodifiedyouareprompted C-xC-c QuitEmacs kill-emacs tosavethechangesordiscardthem. C-g M-xkeyboard-quit Ifyouareinakeyrequestsequencethatyoucan'tgetoutof,thisreturnsyoutothemainbuffer. M-xkeyboard- Doesaboutthesamethingas"C-g" ESCESCESC escape-quit C-xk M-xkill-buffer Killsthecurrentbuffer.Ifthebufferismodifiedyouarepromptedtosaveit. Filesanddirectories Openafile.Thispromptsforthenameofafile.Onceyouhavetypedthefileitopensitinthecurrent buffer.Ifthefiledoesn'texist,ablankbufferiscreatedandEmacsallowsyoutobegintyping(Inthiscase C-xC-f M-xfind-file thefilewillnotexistonthesystemuntilyousaveitthefirsttime).Whenyouaretypingthenameofthe file,youmayusethetabkeyforfilenamecompletion.AlsoyoumayuseM-pandM-ntogotothe "previous"and"next"filesthathavebeenfoundusingfind-file. C-xC-s M-xsave-buffer Saveafile.Thissavesthecurrentbuffer. MoreHere.Thisopensthedirectoryspecified(samewayasfind-file).Itopensabufferthatliststhe http://seamons.com/emacs/ 08/25/03 EmacsQuickReference Page2of4 directoryandallowsyoutoperformoperationsonthefiles.listedinthatdirectory.Therearemany M-xdired(directory features(tomanytolisthere)thatIwillgointolater.Themostbasicistoputthecursoronthefileyou C-xd edit) wantandhitENTER.Thisdoesafind-fileonthatfile. C-xC-w M-xwrite-file Savethecurrentfileas... C-xi M-xinsert-file Insertafile Buffers Thislistsallbuffersthatareopen.Emacswilltypicallyopenabufferforeachfilethatyouvisit(ifyouvisit anewfilewithoutclosinganoldone).Thiswillgiveyoualistofallofthecurrentlyopenbuffersandwill allowyoutochooseonefromthelisttoswitchto.(Youwillnoticethereareacoupleofbuffersbeginning C-xC-b M-xlist-buffers withan*.ThesearebuffersusedbyEmacstostoreoutput.Youmaykillthemifyoulike.)Ifyouhavea fileopenedmultipletimes,youwillseeitlistedas"file"and"file<2>".Thislistofbuffersiscalledthe bufferring Switchbuffers.Doesjustthat.Thedefaultbuffertoswitchtoisthelastonethatyoucamefrom. M-xswitch-to- C-xb (TypingC-xbENTERrepeatedlyswapsbetweenthecurrentandthelastbufferlikeALT-TABin buffer windows.)YoumaytypeaTABtocompletethebuffernameorTABTABtoseealistofallofthebuffer namesyoucantype. C-xk M-xkill-buffer Killsthecurrentbuffer.Ifthebufferismodifiedyouarepromptedtosaveit. Windowsandframes Killsthecurrentwindowifmorethanoneisvisible.Thebuffercontainedinthewindowisputbacktothe M-xdelete-window C-x0 bufferring. M-xdelete-other- Ifmorethanonewindowisvisibleinthecurrentviewingframe,itremovesallbutthecurrentwindow. C-x1 windows Otherbuffersremainopenbutunviewed. M-xsplit-window- Splitsthecurrentviewingwindowintotwowindowsplacedoneovertheother. C-x2 vertically M-xsplit-window- Splitsthecurrentviewingwindowintotwowindowsplacedsidetoside. C-x3 horizontally C-xo M-xother-window Switchesbetweentwowindows. MovingAround C-p(up arrow) M-xprevious-line Movestothepreviousline. C-n(down arrow) M-xnext-line Movestothenextline. C-f(right arrow) M-xforward-char Moveforwardonecharacter C-f(left arrow) M-xbackward-char Movebackwardonecharacter M-f M-xforward-word Moveforwardoneword. M-xbackward- Movebackwardoneword. M-b word M-xbeginning-of- Movetothebeginningoftheline. C-a line C-e M-xend-of-line Movetothebeginningoftheline. M-xbackward- Movebackwardonesentence. M-a sentence M-xforward- Moveforwardonesentence. M-e sentence C-v M-xscroll-up Pagedownonepage. M-v M-xscroll-down Pageuponepage. M-> M-xend-of-buffer Movestotheendofthebuffer. M-xbeginning-of- Movestothebeginningofthebuffer. M-< buffer C-x] M-xforward-page InmostmodesdoesthesameasM-> M-xbackward- InmostmodesdoesthesameasM-< C-x[ page Gotoline.Doeswhatitsays.Ican'tbelievethatthereisnotadefaultkeybindingforthis(thereisin M-xgoto-line XEmacs).Iusuallysetupinmy.emacsfiletheline(global-set-key "\M-g" 'goto-line)whichtellsemacsto useM-gtorunthecommand. C-xo M-xother-window Switchesbetweentwowindows. Switchbuffers.Doesjustthat.Thedefaultbuffertoswitchtoisthelastonethatyoucamefrom. M-xswitch-to- C-xb (TypingC-xbENTERrepeatedlyswapsbetweenthecurrentandthelastbufferlikeALT-TABin buffer windows.)YoumaytypeaTABtocompletethebuffernameorTABTABtoseealistofallofthebuffer namesyoucantype. M-xset-mark- C-SPC command SetMark.Setsthemarktothecurrentcursorlocation(point).Manycommandsarerunontheregionin http://seamons.com/emacs/ 08/25/03 EmacsQuickReference Page3of4 betweenthepointandmark. M-xexchange- Exchangesthepoint(cursorlocation)andthemark. C-xC-x point-and-mark CopyingandDeletingstuff C-_ M-xundo Undo.Undoesthelastcommand.Canbedonerepeatedly. C-d M-xdelete-char Delete.Deletesthecharacterunderthepoint(afterthecursorlocation). M-xdelete- .Deletesthecharacterbeforethepoint(beforethecursorlocation). BACKSPC backward-char Delete M-d M-xkill-word Killsthewordafterthecursorlocation.Placesonthekillring. M-xbackward-kill- Killsthewordbeforethecursorlocation.Placesonthekillring. M-BACKSPC word Kill.Killsfromthepointtotheendoftheline.Ifrepeatedinarow,allofkillsgointothesamekillring C-k M-xkill-line entry.Doingthisoncedoesnotkillthenewlineattheendoftheline.Repeatingkillsthenewline.(for example,tokilltheentirecurrentlineyouwouldtypeC-atomovetothebeginningoftheline,andC-kC-k tokillthelineandthenewline). C-y M-xyank Yank.Insertsthelastentryfromthekillring.Thiscanbedonerepeatedly. M-y M-xyank-pop Cyclethroughthekillring.OperatesonlyifthelastcommandwasC-y M-xset-mark- .Setsthemarktothecurrentcursorlocation(point).Manycommandsarerunontheregionin C-SPC SetMark command betweenthepointandmark. Killsthetextbetweenthemarkandthepoint.Placesonthekillring.Ifthebufferisreadonly,placestext M-xkill-region C-w onkillringbutwarnsaboutnotbeingabletomodifybuffer. M-w M-xkill-ring-save Placestextbetweenmarkandpointonthekillringwithoutkillingtext. M-z M-xzap-to-char Deletesthetextfromthepointuptothefirstinstanceofthespecifedcharacter SearchandReplace M-xisearch- Searchesforwardforthetypedintext.C-srepeatedlysearchesforwardmultipletimes.C-rswitches C-s forward directionofsearch. M-xisearch- Searchesbackwardforthetypedintext.C-rrepeatedlysearchesbackwardmultipletimes.C-sswitches C-r backward directionofsearch. Requeststwopatterns.Searchesforfirstpatternandreplaceswithsecondpattern.Promptsateach M-xquery-replace M-% match.(yfor"yesreplace",nfor"nonext",and!for"replaceall"). M-xisearch- Searchusingaregularexpression(asyoutypeit). C-uC-s forward-regexp M-xquery-replace- Queryreplacesusingaregularexpressionasthematch. M-C-% regexp Fixingupthetext M-xindent-relative- Indentthetextaccordingtotheprogrammodeyouarein. TAB maybe M-C-\ M-xindent-region Runsthe"TAB"onalllinesintheregion. M-u M-xupcase-word Uppercasifiesfromthepointtotheendoftheword. M-xdowncase- Lowercasifiesfromthepointtotheendoftheword. M-l word M-xtranspose- Swapscharactersbeforeandafterpointwithoneanother. C-t chars M-xtranspose- Swapscurrentandnextwordwithoneanother. M-t words Dired-DirectoryEditor Thisopensthedirectoryspecified(samewayasfind-file).Itopensabufferthatliststhedirectoryand M-xdired(directory allowsyoutoperformoperationsonthefiles.listedinthatdirectory.Therearemanyfeatures(tomanyto C-xd edit) listhere)thatIwillgointolater.ThemostbasicistoputthecursoronthefileyouwantandhitENTER. Thisdoesafind-fileonthatfile. M-xdired- RunsaC-xC-f(find-file)onthecurrentlyhighlightedfile.Ifthefileisadirectory,thatdirectorywill advertised-find-

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us