Efficient Movement with Emacs Key Bindings - Emacs Essentials #2

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ก.พ. 2025

ความคิดเห็น • 81

  • @markowen4326
    @markowen4326 3 ปีที่แล้ว +18

    Even when I wasn't using Emacs much, Ctrl + A and Ctrl + E helped so much at the shell prompt.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +5

      Yep, and I forgot to mention that these bindings can also be used in Bash!

    • @mbarton98
      @mbarton98 3 ปีที่แล้ว +4

      I use C-r all the time to search the command history in the shell.

    • @exnihilonihilfit6316
      @exnihilonihilfit6316 2 ปีที่แล้ว

      @@mbarton98 and C-s to go back...

    • @friedrichmyers
      @friedrichmyers ปีที่แล้ว +1

      I used the standard keys for editing text since the old days. Ctrl and arrow keys. Home, page up/down, End and some shortcuts.

    • @shallex5744
      @shallex5744 7 หลายเดือนก่อน

      @@friedrichmyers i guess it depends on what you mean by old days then. i consider all those keys you mentioned except for ctrl to be more of modern inventions/standards

  • @AaronDarkPhoenix
    @AaronDarkPhoenix 3 ปีที่แล้ว +27

    Disclaimer: I have not seen the entire video yet, but it seems like this binding is not very well known so I might as well give it there (although to be fair, it is usually not the most useful): M-m calls "back-to-indentation', i.e. it moves the point at the first non-whitespace character of the line !
    Another cool trick is that you can easily change how the M-a and M-e (beginning and end of sentence) bindings work, by tweaking some variables that you can find in the documentation of the function "sentence-end". For example, it assumes that sentence are typically ended with a dot and two spaces, which is the American convention - in France, we tend to use a single space after the period, but by changing one variable (setq sentence-end-double-space nil) I can tell Emacs that this is how I want it to understand what a sentence is !

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +5

      Thanks for telling me about M-m! I was actually wondering about this when I recorded the video, glad to know there is a binding for it :)

  • @churchill799
    @churchill799 3 ปีที่แล้ว +7

    Another thing I didn't notice was mentioned is moving by s-exp:
    C-M-f - move forward by s-exp
    C-M-b - move backward by s-exp
    It's especially useful for moving around the code where there are brackets, parentheses etc.
    Although not elegant I also find myself using numeric argument followed by C-n or C-p - this is often better than centering the pointer; especially that numeric argument done with C-9 is quite easy for fingers to complete it with C-n or C-p. Not very slick, but sometimes does the job.
    I know It's the matter of personal preferences and years of customization and so on but... It's probably C-s and C-r (searching for text) which calls for mastering and is used by most skilled Emacs users who teached the eye to find unique word in particular place of interest to be navigated to. Sometimes you would think that you cannot beat a person using a mouse but think about the times where you don't exactly remember the spot that particular word is in - this is the appliance I'm thinking shows the efficiency of this method the most.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +2

      Yep, the sexp movements are useful when editing Emacs Lisp but I avoided those for now since this video is more beginner-focused and I don't want to talk about Emacs Lisp too much just yet. I also haven't mentioned numeric arguments yet, but I probably should before long!
      Yep, I agree that C-s can be a very useful tool not just for searching but primarily for navigating to the thing you currently see on the screen. Hopefully I explained it well enough to make it clear that this is the important reason to use it!

  • @OrcsBR
    @OrcsBR 3 ปีที่แล้ว +1

    This is amazing man!! great quality screencast and content as well. Im definitely going to hang out a lot around here

  • @antoniocorbibellot6532
    @antoniocorbibellot6532 3 ปีที่แล้ว +2

    Hi David! Some useful keybindings I didn't know about, thx!
    For the mouse die-hards here I usually define this mouse+key combo for scrolling the document: (bind-key [S-down-mouse-1] #'mouse-drag-drag) , You can drag your document up/down/right/left with shift + mouse-button1 click and move.
    Hope is useful for someone.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว

      That's great, thanks a lot for sharing it!

    • @antoniocorbibellot6532
      @antoniocorbibellot6532 3 ปีที่แล้ว +1

      @@SystemCrafters thx!
      I also used to define Control+mousewheel-up/down to increase/decrease font size...but it seems emas 27 does it...at least for me, I've removed those mouse+keybindings from my config and they still work :)

  • @tchristiansen8001
    @tchristiansen8001 3 ปีที่แล้ว +4

    C-s will search and find, however if you do NOT hit RET but then instead press cancel (C-g) it will send you right back where you started your search. Very useful when just checking something.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +2

      Argh, I forgot to mention that, thanks for bringing it up!

  • @pwojtcza
    @pwojtcza 3 ปีที่แล้ว

    Thank you David - used vanilla emacs Keys for long time, and still managed to get few i never knew existed because i bound them to something else long time ago :)

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว

      lol, yeah, I have trashed the default bindings with my own so I always have to go look up the default bindings in the manual :)

  • @appenzell958
    @appenzell958 3 ปีที่แล้ว

    Always nice to refine movement skills in applications.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +1

      It's definitely a quick win to make switching to Emacs more worthwhile!

    • @appenzell958
      @appenzell958 3 ปีที่แล้ว +1

      @@SystemCrafters True, your channel has really helped make Emacs worthwhile. It's such a nice editor.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +2

      @@appenzell958 So glad to hear that! Emacs is a lot of fun :)

  • @thatsamorais584
    @thatsamorais584 3 ปีที่แล้ว +1

    This is absolutely critical to master

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +1

      You'll be zoomin' around like a ninja

    • @thatsamorais584
      @thatsamorais584 3 ปีที่แล้ว +1

      @@SystemCrafters I'm gonna put a throwing star into my IDE

  • @potatoeater5987
    @potatoeater5987 3 ปีที่แล้ว +3

    I am currently learning the modal system xah-fly-keys. Really liking it coming from vim! It has awesome support for different keyboard layouts.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +3

      I've never tried xah-fly-keys, but I did use ErgoEmacs many years ago (which I think Xah also created, if not mistaken). I'll have to cover some of these alternate key layouts in the future!

    • @maksimbronsky7117
      @maksimbronsky7117 3 ปีที่แล้ว

      me too :-)

    • @linuxramblingproductions8554
      @linuxramblingproductions8554 2 ปีที่แล้ว

      What do you think of it now are you still using it

  • @Ggldoork
    @Ggldoork 2 ปีที่แล้ว

    Your videos are the best.

  • @kp1498
    @kp1498 3 ปีที่แล้ว +1

    I migrated to Emacs from Vim, and only after that the absence of hjkl showed me how much I got used to them and the other vim bindings :) So after not very long, I became a happy Evil user, just as the overwhelming majority of émigrés, according to the latest Emacs survey

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +2

      Yep, I'm also an Evil user! I had to review the Emacs documentation to learn about a few of the things I mentioned here :)

    • @bendirval3612
      @bendirval3612 2 ปีที่แล้ว +1

      @@SystemCrafters It's too bad emacs wasn't designed from the ground up with vim-style modal editing and vim or vim-like keybindings. If that had been the case, there would be no need for vim and everyone would use emacs. Evil is a nice way to have one foot on either side of the fence, but it's not without problems.

  • @charlessmith5465
    @charlessmith5465 3 ปีที่แล้ว +1

    I like to set some of the default-unbound Function-keys to open files I acces the most. F7 maps to open an org file full of my web bookmarks for example. I started computing with MS-DOS and remember when software often came with overlays for the F-keys which matched their meaning within the program, which was actually pretty user-friendly without needing to memorize keychords or function names.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +2

      I remember those little plastic cards you can place around your function keys to remember what they do for a given program :) This is a great approach, I actually never use the F keys for bindings but maybe I should!

    • @charlessmith5465
      @charlessmith5465 3 ปีที่แล้ว +1

      @@SystemCrafters F5 pulls up my emacs dotfile, F3 opens the buffer-menu. The main thing is to [C-h k F3] etc first to make sure it's not already bound to something else, or to check that your window manager doesn't trap it. It can also get trickier if you sometimes use emacs in a terminal: whether the key or chord makes its way down into Emacs can get confusing.

    • @nisdonatzsky
      @nisdonatzsky 3 ปีที่แล้ว

      @@SystemCrafters I have C-F5 - F9 set to visual aids.
      (global-set-key (kbd "C-") 'display-line-numbers-mode)
      (global-set-key (kbd "C-") 'whitespace-mode)
      (global-set-key (kbd "C-") 'highlight-indent-guides-mode)
      (global-set-key (kbd "C-") 'hl-line-mode)
      (global-set-key (kbd "C-") 'visual-line-mode)

  • @Gollum999
    @Gollum999 3 ปีที่แล้ว +1

    How do you hide the org-mode markdown syntax until your point is inside a marked-down region? e.g. at 10:45

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +2

      This is the org-appear package, it only works for Org Mode files: github.com/awth13/org-appear

    • @Gollum999
      @Gollum999 3 ปีที่แล้ว +2

      @@SystemCrafters Awesome, thanks!

  • @manningermani
    @manningermani 11 หลายเดือนก่อน

    Great series! What package are you using for the presentation?

    • @SystemCrafters
      @SystemCrafters  11 หลายเดือนก่อน

      Thanks! It's Org Present with my own customizations. Check out my video "The Secrets of My Presentation Style" for the full setup

  • @Anton-vu1ou
    @Anton-vu1ou 3 ปีที่แล้ว +1

    It's so cool! Continue to make Emacs videos!)

  • @mbarton98
    @mbarton98 3 ปีที่แล้ว

    Nice refresher and learned about C-M-l and am now questioning why I use avy goto rather than C-s. Avy can jump to another visible buffer, but I end up wasting time deciding if I want to search for something on the screen or not on the screen. I like the idea of muscle memory hitting C-s while I decide.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว

      I use avy, but not as reflexively as I should. The one thing I don't like about C-s is that you have to press RET to finish jumping to the next location, avy makes that experience a little bit smoother. Trying to use C-s as a default behavior isn't bad though!

  • @bjarnisg
    @bjarnisg 3 หลายเดือนก่อน

    Hmm... weird, the "M f" keybinding to move forward one word, is not working out of the box 🤔
    Going back one word with "M b" and even selecting one word forward with "M-S f" is working though.
    What might be causing this inactivity? 🤷‍♂

    • @bjarnisg
      @bjarnisg 3 หลายเดือนก่อน

      ....Figured it out why M-f was not working. There was a conflict between Emacs and other program running in the background.

  • @mohamedmurshid9794
    @mohamedmurshid9794 ปีที่แล้ว

    I don't see in much tutorials and blog posts that C-m also does same thing as RET(Enter key). Which is easier than enter key in my opinion.

  • @ganainm01
    @ganainm01 3 ปีที่แล้ว

    How do you configure Emacs so that emphasis markers are automatically unhidden once you move point into a marked-up section? Like jumping onto "paragraph-start" instantly unhides the verbatim markers and shows "=paragraph-start="?

  • @xvnz
    @xvnz 3 ปีที่แล้ว

    8:35 maybe this is just worded wrong but shouldn't left-char/right-char *ignore* right-to-left text because left and right are still left and right? forward-char and backward-char are the ones that should respect text direction.

  • @davidjeters
    @davidjeters 3 ปีที่แล้ว

    Hey David, what is the keycasting package that you are using in the video? Can you provide a link?
    Also in regards to scrolling do you think the name has something to with the old days when computers used paper for memory, such as punch cards? Old typewriters used to have a scroll wheel(A least I think it was called a scroll wheel) on the side. When you would scroll up it would cause the paper to move up thus bringing you closer to the bottom/end of the paper.

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว

      Hey David! It's called Keycast: github.com/tarsius/Keycast.
      You could be right! The terminology in Emacs is so old that it must be influenced by the technology and concepts of the time

    • @peterkois4858
      @peterkois4858 3 ปีที่แล้ว

      @@SystemCrafters Could you in your show notes write keycast config for emacs from scrstch and doom also?

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +1

      @@peterkois4858 Check out the "use-package keycast" part in this section of my personal config, it should work with both: config.daviwil.com/emacs#streaming

  • @merryMellody
    @merryMellody 3 ปีที่แล้ว +2

    Thank you for making this video!
    I love your Emacs videos, but I was always a bit bummed you jumped right into using Evil from nearly the very beginning.
    I get that there are a lot of Vim converts, and Evil is a quality package, but I find that it’s good to learn a new system’s intended workflow before you try to coerce it into one of your own :-)
    But still, hacking the editor is what Emacs is all about!

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +6

      Yep, I was basically just showing how to replicate my own configuration in the early Emacs From Scratch videos so it was Evil-focused. My goal with the Emacs Essentials series is to make up for that by covering only things that are built in to Emacs!

    • @merryMellody
      @merryMellody 3 ปีที่แล้ว

      @@SystemCrafters very cool! I completely understand. Thank you for helping people like me nerd out on a text editor!

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +3

      We're all nerding out together here :)

    • @fennecbesixdouze1794
      @fennecbesixdouze1794 3 ปีที่แล้ว

      Couldn't disagree more. They aren't "the vim key bindings", they are used throughout a lot of applications, like less/more, screen, hell even the Gmail webpage uses j/k for scrolling up and down through emails (presented as lines) and x for deleting etc etc. And many of the commands get used in other places, e.g. like ^, $, / in regex. Familiarity with these bindings is universally helpful.
      I don't really see Emacs as having "editing key bindings" that are at all fundamental, Emacs has /modes/, all with their own bindings and that's fundamental to how Emacs works. I think the Evil bindings fit perfectly into the ethos of Emacs.

    • @bendirval3612
      @bendirval3612 2 ปีที่แล้ว

      @@fennecbesixdouze1794 Other applications use vim bindings because the vim key bindings are pretty good and designed for humans to get work done without leaving home row. If I had a finger in the middle of my palm that could press the alt key, I might be more open to the default emacs bindings. They are just so awful!

  • @jparaujobezerra
    @jparaujobezerra 3 ปีที่แล้ว

    Hi, great video, This apresentation, what softare is using?

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +4

      Thanks! This is actually an Org Mode file displayed in Emacs with the org-present package (and some tweaks of my own): config.daviwil.com/emacs#org-present

    • @charlessmith5465
      @charlessmith5465 3 ปีที่แล้ว +2

      @@SystemCrafters the first time feeling of realizing how much of an operating system and IDE Emacs is: 🤯😆

  • @robinmattheussen2395
    @robinmattheussen2395 3 ปีที่แล้ว

    I'm stuck in this awkward spot where I'm not a vimmer, so I have quite a bit of difficulty getting used to modal editing and the hjkl workflow, but at the same time I also struggle to be efficient using the native Emacs navigation keys (which can be a little bizarre). I'm decent at elisp, am familiar with a lot of the core concept of Emacs and even have quite the elaborate configuration that I created myself, but for some bizarre reason I keep on struggling with basic navigation in Emacs, and it's one of the primary reasons why I can't get used to Emacs as my daily driver. It's quite frustrating, and I'm not sure how to improve my skills.

    • @AndersJackson
      @AndersJackson 3 ปีที่แล้ว

      I try to remember the menmonics, and typing them are like typing text, so there are no problem finding the keys.
      And touch typing are a skill you need to have. At least a decent one.
      And a tip, learn how to remove a word, as that is often faster to retype a word then to back to right place and to retype the whole word. Unless you type in German and Swedish, with loong words. :-)

  • @ce9916
    @ce9916 3 ปีที่แล้ว +1

    The content you came for starts at 2:30

  • @richardfrangie3518
    @richardfrangie3518 2 ปีที่แล้ว

    👍

  • @akojic5486
    @akojic5486 3 ปีที่แล้ว +1

    First learn basic, then learn colemak keyboard with hax-fly-keys.. This is my setup, it is hard but worth it every penny on long term, if you code like me all day long dont stick to qwerty keyboard, it is not natural, dvorak or colemak(easier to switch from qwerty)

    • @subarutendou
      @subarutendou 3 ปีที่แล้ว +1

      I done do the same think but with dvorak, because orther than english I’m typing chinese and japanese too. At the time I search for alternative keyboard layout to reduce my pinky pain, that’s what I found, all the people I saw said the colemak only for english then I found xah-fly-key and his website.

    • @akojic5486
      @akojic5486 3 ปีที่แล้ว +1

      @@subarutendou nice dude, you are like my brother :-)))

  • @bendirval3612
    @bendirval3612 2 ปีที่แล้ว +1

    Those keybindings are all so awful, to be frank. There's a reason people force emacs to use vim keybindings. EVERY keystroke that requires the meta key requires removing my hands from home row, and probably searching around as well and possibly hitting the windows key by mistake--both alt keys are directly under a palm. Don't get me started on chords that require meta, control, shift, and one or two other letters!

  • @DarkBraveStuff
    @DarkBraveStuff 3 ปีที่แล้ว

    C-M-l logs me out of Plasma :(

  • @thomasvoneyben8397
    @thomasvoneyben8397 3 ปีที่แล้ว +1

    My mnemonic for ‘a’ = stArt... :-)

    • @SystemCrafters
      @SystemCrafters  3 ปีที่แล้ว +1

      That is much better!

    • @bullpup1337
      @bullpup1337 9 หลายเดือนก่อน

      a=anfang, e=ende… Germans have it easy.

  • @sarthaktanwani2314
    @sarthaktanwani2314 ปีที่แล้ว

    Why is Gavin Belson teaching me emacs?💀