Search:

PmWiki

pmwiki.org

edit SideBar

Main / Emacs

ctrl x, ctrl f = open
ctrl x, ctrl v = reload file
ctrl x, k = close file (aka kill buffer)
ctrl x, ctrl s = save
ctrl x, ctrl w = save as

ctrl x, arrow = switch buffer
ctrl x, 0 = clear extra buffer windows
ctrl x, b = pull up specific buffer (also works well as a recall previous)
ctrl x, ctrl b = list buffers

crtl x, ctrl e = evaluate expression on the line (must highlight entire expression)

ctrl x, h = select all
alt w = copy
ctrl w = cut
ctrl y = paste
ctrl k = delete line
ctrl x, space = begin mark for rectangular (column) select

ctrl c, ctrl f = copy file path to clipboard (not the primary selection)

ctrl s = search
ctrl r = search reverse
ctrl s, ctrl w = highlight word at cursor and search
alt shift 5 = replace
alt g, g = goto line

ctrl x, tab = block indent interactive (follow with arrow key control)
alt i = indent
ctrl u, <num>, ctrl x, tab = force indent by <num> spaces (uses SPACES), block supported
alt x = invoke Emacs command line
ctrl q, tab = force insert a tab character (not spaces)

ctrl h, k = describe key
alt shift : = command line prompt for eval

alt x, hexl-find-file = lets you open a binary file in hex format

Accessing complex instructions

alt x, recover-file = restore auto-save file (#filename#.ext)
alt x, delete-trailing-whitespace = remove trailing spaces

Config

To diagnose problems with the config file run with --debug-init
Emacs Config File
https://www.emacswiki.org/emacs/buffer-stack.el (about)
http://www.emacswiki.org/emacs/download/buffer-stack.el (download)

To add an emacs plug-in, download the .el file and place into ~/.emacs.d/ Then add these lines to .emacs

(add-to-list 'load-path "~/.emacs.d/")
(load "myplugin.el")
(require 'myplugin)

Features of my config file:

ctrl ; = block comment
ctrl ' = block uncomment
alt left = prev buffer
alt right = next buffer
ctrl z = undo
ctrl c, ctrl f = copy file path
alt up, alt down = scroll one line
ctrl+shift d = add disassembly pane

I have included ibuffer which is an add-on improvement over the standard buffer listings.
http://mytechrants.wordpress.com/2010/03/25/emacs-tip-of-the-day-start-using-ibuffer-asap/

Other hints about buffers
http://www.gnu.org/software/emacs/manual/html_node/elisp/The-Buffer-List.html

How to assign syntax highlighting to an unrecognized file extension

http://unix.stackexchange.com/questions/25184/emacs-file-extension-recognition

Font face manipulation

alt-o, d Remove all face properties (facemenu-set-default).
alt-o, b Apply the bold face (facemenu-set-bold).
alt-o, i Apply the italic face (facemenu-set-italic).
alt-o, l Apply the bold-italic face (facemenu-set-bold-italic).
alt-o, u Apply the underline face (facemenu-set-underline).
For this to stick when you save and close, you must enable enriched mode with alt-x enriched-mode.

Why are my makefile comments highlighted?

The indented ones are because they are passed by make to the shell as commands and are not interpreted immediately as comments.

Link Highlighting

https://emacs.stackexchange.com/questions/4001/saving-and-restoring-highlighting-patterns
https://stackoverflow.com/questions/385661/how-to-highlight-all-occurrences-of-a-word-in-an-emacs-buffer
ctrl-x w p phrase <RET> face <RET>
To create an init action that happens every time a file is opened, you have to reference it with add-hook and use find-file-hook.

File Mode Edits

ctrl-h, v major-mode
tells you what file mode you are in. You can view any variable's current value with
ctrl-h, v

For shell scripts,
to set the wrapped-line continuation indent, TODO - nothing is working, emacs is broken
to set the default new line tab width, use (setq sh-indentation 2);

Source Tagging for Reference Linking

Cscope

Install Cscope and the Emacs lisp extension with sudo apt install cscope cscope-el.

cscope -R at top level will generate the database and launch the UI.
cscope -R -b will not launch the UI.
ctrl D will exit.

etags

This will take in all the .c/.h/.cpp/.hpp files in the tree where executed and generate a TAGS file:

find . -type f -regex ".*\.*[ch]\(pp\)?$" | etags -

alt . = find definition
alt shift ? = find references (only works in emacs v25+)

The first time you try to use it, Emacs will ask where the TAGS file is location. After that you should be fine.

Update Notes

Apparently pc-selection-mode is obsoleted and replaced with delete-selection-mode

List of Emacs options

https://docstrings.github.io/list.html


Page last modified on September 18, 2024, at 12:32 PM