Tag: keyboard shortcuts

  • Emacs: yank a line multiple times from the kill ring

    Emacs: yank a line multiple times from the kill ring

    Today I needed to copy a line multiple times in emacs. I needed 8 copies, but how to do that in emacs short of pressing C-y to yank 8 times? My initial guess was to try C-u 8 C-y but that yanks the 8th item from the kill ring.
    Fuco on #emacs supplied the awesome answer:
    F3 C-y C-8 F4
    So what does that do? F3starts recording a macro, C-yyanks the line, then within the macro itself you can add a numeric argument of 8 using C-8. End recording of the macro with F4. Emacs then runs the macro 8 times. Recall that pressing F4 after ending recording of the macro runs the macro.

  • Edit a regex search string in Emacs

    If you are writing a complex regex search in emacs and need to edit the string, arrow keys takes you out of the search. M-e allows you to really edit the string.

  • The Mark Ring in emacs

    Each time you mark with C-<SPC>, Emacs saves the mark in the mark ring.
    You can step back through your mark ring with C-u C-<SPC>.
    You can swap point and mark with C-x C-x.

  • Re-reading the emacs tutorial

    It came upon me to re-read the emacs tutorial. Last time I read it was probably about 17 years ago. Things might have changed since then.
    I picked up two things:
    C-/ is undo and is equivalent to C-_
    C-h c gives you brief help on a keyboard shortcut. I was using C-h k but that opens a new window which can be annoying sometimes.
    C-h t takes you to the tutorial.

  • Swap Registers in emacs calc

    <TAB> to swap the contents of the last two registers in calc.

  • emacs keyboard macros

    If you haven’t explored the power of keyboard macros in emacs, you should.
    You only need to remember a few keys to get going:

    <F3> Start recording a macro
    <F4> End recording a macro
    C-x e to repeat the macro
    

    Give it a go!

  • Select what you typed rather than the completion in ido-mode

    Sometimes you don’t want the completion that ido is offering me in Emacs, for instance when trying to create a temporary buffer C-x C-b sometempbuffername. C-j will to get ido to accept what you typed rather than the completion.

  • Keyboard shortcut to un-minimise a window in OS X

    It’s a bit fiddly but it can be done.
    Cmd+m to the item you want to un-minimise, then while still holding cmd, press Option. Release Cmd and then finally release Option.

  • Cmd+m to Minimise a window in OS X

    Cmd+m to minimise a window in OS X

  • Insert a new heading after numbered list in org-mode

    In org-mode in emacs, M-<RET> will add either a new heading or if your insertion point is between a list item and a heading, it will add a new list item. This is not always desirable. To add a new heading try C-U M-<RET>.
    I only discovered this as I got frustrated with org-mode insisting on adding an item to the list rather than creating a new heading. The emacs way around problems like this is to prefix the command with C-U to make it do something slightly different.