Emacs musings (was: Re: put cursor on found text in less or vi?)

Little Girl littlergirl at gmail.com
Fri Sep 27 00:51:19 UTC 2024


Hey there,

Paul Smith wrote:
>Little Girl wrote:

>Out of curiosity I tried your must-have items.

I appreciate that.

>The CLIPBOARD is what's updated (from the PRIMARY selection) when you
>use C-c and pasted when you use C-v (in most programs, not Emacs). 
>See: https://en.wikipedia.org/wiki/X_Window_selection
>
>If by PRIMARY you mean the same thing as what I call CLIPBOARD,

I did. My mistake.

>then this is the default behavior in Emacs.  That is, if I select
>text in my browser and use C-c to copy it, then in an Emacs buffer
>pressing S-Ins will paste it.  Similarly, if I select text in an
>Emacs buffer and press S-Del it is cut in the Emacs buffer, then in
>some other program using C-v will paste that text.

Good so far.

>>  * Home and End should take me to the beginning or end of
>>    the current line
>
>This is not the default behavior: by default Home and End move to the
>beginning/end of the logical line, not the beginning/end of the
>physical line if it wraps.  However you can change this by adding:
>
>  (global-set-key [home] 'beginning-of-visual-line)
>  (global-set-key [end]  'end-of-visual-line)
>
>to your ~/.emacs.d/init.el file.

Good to know and easy enough to do. Thanks.

>>  * Ctrl+Home and Ctrl+End should take me to the beginning or
>>    end of the document.
>
>This is the default behavior.

Also good.

>>  * Ins and Del should insert or delete at the position of the
>>    cursor.
>
>I'm not sure I understand this.  In Emacs the cursor is conceptually
>between two characters (even if you display it as a block cursor
>instead of a bar cursor).  The Del key deletes the character to the
>right of the cursor, and Backspace deletes the character to the left
>of the cursor.

That's exactly what I meant and is perfect.

>The Ins key toggles overwrite mode.

There's my wall and that would send me scampering. Can it also be
overridden in the configuration file so that pressing the Ins key
pastes the cut or copied text at the cursor instead?

To be specific, I mean that if I have apple|coconut (with the pipe
representing the position of the cursor rather than an actual
character), if banana is on the clipboard and I press the Ins key, I
will get applebanana|coconut (with the pipe representing the position
of the cursor rather than an actual character).

>Different keys can (and do) map to the same command.  So, the
>"traditional" C-a maps to beginning-of-line, but so does Home.

That's perfect. Several programs are like that and it's something I
heartily approve of since it pleases a variety of people.

>I'm not sure if C-a is an example of what you mean by "two-key key-
>combination".

It was used to distinguish from my single-key press of the Home or
End key as opposed to pressing two keys at once, like Ctrl + some
other key, to do the same thing.

>> https://www.youtube.com/watch?v=X_iX5US1_xE
>
>I've seen that one.  This is better than some but to me it still gets
>too far down in the weeds, certainly in the beginning.

Yeah. I figured I'd warn you about that first minute of repetitive
stuff.

>Plus he's using Evil mode which means he's using a vi interface, not
>actually using normal Emacs keybindings.

Those of us who don't use any of that software would never have
known.

>IMO a good introductory video should be all about features and not
>mention things like "how to move the cursor" at all, and it
>shouldn't rely on highly user-specific configurations.

Agreed. It sounds like you could do a nice focused one.

>There is also Forge https://github.com/magit/forge which provides a
>Magit-based integration with forges like GitLab and GitHub: it allows
>fetching issues, managing PRs, etc.  I don't use this much myself.

Thanks. Good to know.

>> Using it would involve learning lots of new shortcuts.
>
>That is true, although they're pretty mnemonic: "s" to stage, "u" to
>unstage, "p" to push, "f" to fetch, etc. etc.

I know they seem simple, but when you use a lot of software, trying
to remember the shortcuts each program uses, no matter how simple, is
a maddening chore, especially for those of us who like to rely on
muscle memory for frequent tasks. It's gentler to not learn them at
all and just stick with the universal ones in all programs, thus
saving all of the available real estate on your mental shelves for
the things you're interested in doing.

>There is also great pop-up help by typing "?".

That's definitely very useful. Thanks.

-- 
Little Girl

There is no spoon.




More information about the ubuntu-users mailing list