A new file can be created in two ways:
$ emacs
my_new_file
. This will open a new empty buffer.C-x b
name of the buffer
RET
. This creates a new buffer you can edit. You can then save
to a file.Use C-x C-s
to save a buffer changes to a file. If there is no file
associated to a buffer, the minibuffer will prompt for one.
Copy-paste is easier to do with CUA mode active. To activate CUA
mode, go to the Options menu and make sure Use CUA Keys is ticked.
To save, Options → Save Options. Another way of activiating it is
by adding the following to your init
file:
(cua-mode t)
Once CUA mode is active, copy-paste functions are bound to the usual keys:
C-c
: CopyC-p
: PasteC-x
: CutAnything that’s “killed” is actually cut, and can be yanked using
C-y
. You can cycle through the previous cut values using M-y
after C-y
as many times as you need.
C-M-SPC M-w
: Select current sexp, and put it in the kill ring.C-k
: kill text to the end of lineC-w
: Kill regionM-d
: Delete word.C-o
: Insert a newlie.C-x C-o
: Delete blank lines, leaving one.C-d
: delete-char
, Deletes the next character. C-u C-d
deletes
all spaces up to next char.M-x flush-lines RET <regexp> RET
: Delete all the lines that match
the regexpM-x sort-lines
: Sort lines.M-x reverse-region
: Reverse order of lines in region.M-^
: Join current line to previous, removing spaces.M-x flush-lines RET ^$ RET
on the current region.M-x delete-duplicate-lines
: Remove duplicate lines.C-u M-| uniq
: Run uniq
command on region.C-_
: undoC-g C-_
: Redo after undoC-g C-/
: Redo after undoWhen CUA mode is active, C-z
also acts as undo.
See also the Emacs Manual.
M-c
: capitalize wordM-u
: uppercase wordM-l
: lowercase wordM-x center-line
: center the text on the line.M-^
: join two lines, removing the extra space.C-t
: transpose characterM-t
: transport wordsC-x C-t
: transpose linesM-x toggle-truncate-lines
: toggle line wrapping.M-SPC
: just-one-space
. Delete all white spaces until the next
non-space char, leaving just one.C-x TAB
: indent-rigidly
. Indentation of region can be adjusted
with C-x 8 RET
: Enters Unicode character by entering its name,
e.g. C-x 8 RET RIGHTWARDS ARROW RET
Next: Search