C-M r regext search backward
C-M s regexp search forward
C-M h select next paragraph

Shift-Mouse3 - run macro

M-x describe-char <RET> when char in cursor position, will show info abt [unicode] char

to input: type "C-x 8 RET 3bc" or "C-x 8 RET GREEK SMALL LETTER MU"

in HTML mode C-c / close the inner tag

when you hit RET on a link in shr/eww, it uses the browse-url browser to follow the link
if you hit `C-u RET', it uses the `shr-external-browser' browser

narrowing is the concept of hiding the buffer contents except for what you are currently working on

---------------------------------------------------------
what's shown	         	                binding
---------------------------------------------------------
region (selection)	narrow-to-region	C-x n n
current page	        narrow-to-page          C-x n p
function	        narrow-to-defun         C-x n d
everything	        widen	                C-x n w
---------------------------------------------------------
    
Registers
-------------------------------------------------------------
C-x r s (#)	        Copy Selection to Numbered Clipboard
C-x r i (#)	        Paste from Numbered Clipboard
C-x r space (#)	Set     Numbered Bookmark
C-x r j /#	        Jump to Numbered Bookmark
-------------------------------------------------------------

C-x C-b choose Window

if you launch emacs using the -nw flag to force a console session (rather than an X session if you have X windows running), how do you get to the menu?

M-x menu-bar-open, which is usually bound to F10. this works with and without menu-bar-mode (which just shows the names of the menus at the top of the screen). in case you have F10 bound to smth else, you can use Ctrl+F10 to get the same effect

C-x b buffer - select or create a buffer named buffer
C-x 4 b buffer - similar, but select buffer in another window
C-x 5 b buffer - similar, but select buffer in a separate frame

    
    to increase the height of the default face in the current buffer
    C-x C-+      or       C-x C-=

    to decrease it
    C-x C--

    to restore the default (global) face height
    C-x C-0

    
C-M f    move forward over a balanced expression
C-M b    move backward over a balanced expression
C-M k    kill balanced expression forward
C-M PC   put the mark at the end of the sexp
C-M e    move forward over a parenthetical group 
C-M a    move backward over a parenthetical group
C-M u    balanced-parentheses from inside
C-M p    jump to prev sexp
C-M n    jump to next sexp
use C-M-right and C-M-left (respectively backward-sexp and forward-sexp) to go to the beginning or the end of the current expression. this works for parenthesis pairs but also for plain words

for parentheses, braces and brackets just double clicking on them does the trick. sometimes it is faster just to click something than to search for it or move the cursor position. double clicking on some parens, bracket or curly braces will move the cursor to the its pair and select the inner contents

* * *

SHift+<left-Mouse> - increase/decrease font-size

M-x set-background-color < name > <RET>

multi-cursor

string replacement with confirmation

M-%   executes the query-replace function. you will be prompted for two strings

beginning at the point, emacs will then search for and stop at every occurrence of the first string

[C-x r l] - bookmarks list

find/replace for all files in a dir

call dired [C-x d] to go to a dir
mark the files you want to work on (m to mark, u to unmark)
call dired-do-query-replace-regexp

 

[C-x d] - "dired"

list matching lines

emacs has a very useful command:

list-matching-lines [M-s o]

emacs will list all lines of current file containing that word. if you want to match with word boundary, use \b, like this \bfoo\b. This will find “foo” but not “foos”. you can click on any matched line in the output, then emacs will put cursor at the position of the occurrence in your file

delete-matching-lines

sort-lines


codepage

Какая правильная последовательность действий в GNU Emacs 24+, если я хочу в разных буферах редактировать тексты в разных кодировках? Когда кодировка одна, я просто запускаю Emacs в соответствующей локали. А когда их несколько?

(set-language-environment "Cyrillic-KOI8")
- ну или что надо - должно хватить. еще есть "Cyrillic-ALT", "Cyrillic-ISO", "UTF-8", "Russian" и тд

In cases where Emacs does not automatically choose the right coding system for a file’s contents, you can use these commands to specify one:

C-x RET f coding RET
Use coding system coding to save or revisit the file in the current buffer
(set-buffer-file-coding-system).

C-x RET c coding RET
Specify coding system coding for the immediately following command (universal-coding-system-argument).

C-x RET r coding RET
Revisit the current file using the coding system coding (revert-buffer-with-coding-system).

M-x recode-region RET right RET wrong RET
Convert a region that was decoded using coding system wrong, decoding it using coding system right instead.


[C-x r o] - add spacebars and start current line with coursor position


[C-o] or [C-j] - add line just after

[C-m] - add line bellow

[M-i] - insert tabulation

insert/delete comment

select a block of text set-mark-command [C+space] to mark, then move cursor
call comment-dwim [M+;] to make the region into a comment or uncomment

to delete the first few n chars of every line

mark [C+Space] the beginning of first line and move cursor to the last line, and move it to the right n chars

then call kill-rectangle [C+x r k]

to replace unprintable characters

call query-replace [M+%]. when you need to insert a tab character, type [C+q] first, then press [Tab]. same for inserting a [Enter]

to change file line endings between Windows/Unix/Mac

set-buffer-file-coding-system , then give a value of “mac”, “dos”, “unix”. save

M-Del     delete the previous word

M-q     with paragraph - concat all strings with space as slice

M-z     delete to char <> (including)

C-u n     repeat the next command n times

C-@     set/unset the mark

C-x r t <pattern> fill rectangle with new content from pattern

shell Command execution

ESC !     shell-command

M-|     shell-command

C-u M-|     shell-command on region

C-x C-d     list directory

previous yank restoration

what do you do if you have some text you want to yank back, and then you kill something else?
[C-y] would yank the more recent kill. but the previous text is not lost.
you can get back to it using the M-y command.
after you have done C-y to get the most recent kill, typing [M-y] replaces that yanked text with the previous kill

others

[C-x C-i] S< | S>     (un)intend region

C-t transpose-letters     switch two letters
M-t transpose-words     switch two words.
C-x C-t transpose-lines     switch two lines.

M-h     select paragraph
M-a     to parag begin
M-e     to parag end

M-r     to begin/end of the buffer

M-l     downcase word
M-c     capitalize word
M-u     uppercase word

C-x C-l     downcase-region
C-x C-u     uppercase-region

M-j     insert line (split line in cursor position)

C-x o     moving between windows
C-x 0    close window
C-x k    kill window
C-x }    enlarge-window-horizontally
C-x {    shrink-window-horizontally


ESC-/
(dynamic-abbrev-expand) automatically completes the word in front of the cursor with one of the words present in one of the files being edited current community

(global-set-key (kbd "C-") 'my-func)


MACROS

F3     start kbd macro

F4     complete kbd macro

C-1..9 F4     run macro n times

C-x C-k n M-x name

in ".emacs" file: M-x insert-macro

fixing underscore and CamelCase statement by :-
M-x superword-mode > Hi_Mr_joker M-x subword-mode > HiMrJoker


C-x a i g    Abbreviation mode
M-x abbrev-mode toggle mode
M-x write-abbrev-file
M-\ Dynamic Abbreviation mode


M-x customize-face RET default
to set font-size
or
(set-default-font "Monaco 14") in .emacs file


M-SPC
reduces the space between words to just one space.

M-\
removes all horizontal space. This will join two words separated by space.


If what you are trying to achieve is some kind of "sparse" formatting, as in:

int foo = 42;
unsigned int bar = 43;

then there's

M-x align-regexp

to do that


M-m     move the cursor to first character in line

C-x 0    close-window

C-x C-f    open a new file
C-x C-s    save the current file
C-x C-c    exit the emacs but save files first


lines

C-a go to the beginning-of-line
C-e go to the end-of-line
C-n go to next-line
C-p go to previous-line
C-k kill the current line
C-o open-line

words

M-f forward-word
M-b backward-word
M-d kill-word

C-m insert line in position
C-k kill the line
C-o insert line below

C-j insert line above

run

M-x run-js

M-x run-haskell

M-x run-ocaml

align

M-x align-str
M-x align-reg
M-x align-

screen

C-l    recenter
C-l C-l    retop
C-l C-l C-l    rebottom
C-v    scroll-up (forward)
M-v    scroll-down (backward)

multiple-cursor-mode

     ------------------------------------------------
    | Hit C-g or RET to exit multiple cursors mode   |
     ------------------------------------------------
 

the command mc/add-cursor-on-click (which I personally have bound to C-S-)

With this setup, I can hold Ctrl and Shift and click the beginning of line 10, and then click the middle of line 34, and I will have a cursor in both positions. You can bind this command the way I have like this in your init:

(global-set-key (kbd "C-S-") 'mc/add-cursor-on-click)

You can replace the kbd with another combination too if you want.

n.b. That's actually an alias for mc/toggle-cursor-on-click -- which is a more descriptive name for what it does

The command I reference is the one Magnars uses in the readme for multiple cursors, and I just copied it from there when I started using the package. I didn't realize it toggled actually, but will experiment with it now. I rarely use the mouse for this anyway, but sometimes (like in the situation in OPs question, it can really come in handy.

I expect the toggling functionality came at some later point, and the original name was retained (in alias form) for backwards-compatibility.

iy-go-to-char

Sometimes, you find yourself needing to move to the next # or the next , or some specific delimiter. This is especially handy when you need to move across different numbers of words for each cursor. It provides the functions iy-go-to-char and iy-go-to-char-backward, which you can bind and use nicely.

Go to the end* of what you want selected.
Press C-S-b or M-S-b to select backwards until you get a portion selected. You can use shift left arrow as well.
Then press C-> (press shift if the key > is on top of your keyboard's key) until you get more than one item selected.
*It is important to select backwards or the first selection will place the cursor in the wrong position.

Say you would for instance define 5 variables with multiple cursors and you wanted to name them x_i where i ∈ {1,2,3,4,5}. Instead of writing 5 rows with x_ and then filling the rest manually, is there any way this could be done with multiple cursors?

Let's say you have atleast 5 consecutive empty lines.
With the cursor at the topmost empty line, create 5 multiple cursors by keeping on hitting C-> (default binding for mc/mark-next-like-this).
Type the common variable prefix: x_ as per your example.
Insert numbers starting with the prefix you specify (default starting number is 0) to mc/insert-numbers. For your example, you would do C-u 1 M-x mc/insert-numbers.
Hit C-g or RET to exit multiple cursors mode.

Say we want to kill the region selected by all cursors in multiple-cursors, and yank it all to a new, empty buffer. How do you do that with multiple-cursors? Note that a simple copy and paste of the text on the new buffer does not work, since it only yanks the region from the first cursor

Once text has been killed, exit multiple-cursor (enter) and while in new buffer hit C-x r y (normally the killed text is in the rectangle kill-ring)

How can I insert a number sequence with the multiple-cursors plugin in Emacs? For example,
aa| aa1
aa| => aa2
aa| aa3

Use M-x mc/insert-numbers. By default, it inserts 0 for the first cursor, 1 for the second cursor etc, but you can change this by using a numeric prefix argument. So to get 1, 2, 3 as in your example, use C-u 1 M-x mc/insert-numbers.