Frequently-used keybindings in aprl-emacs configuration

Table of Contents

aprl-emacs configuration can be found at https://gitlab.com/aprl/aprl-emacs.

all (or most) modes

keybinding function
C-c ; (comment-region)
C-u C-c ; (uncomment-region)
C-M-\ (indent-region)
  • C-c ; toggles comments in auctex.
  • (indent-region) invokes "smart indent" in most modes.

ido-mode

The minibuffer seems busy at first, but will soon make sense. Flex matching is enabled (setq ido-enable-flex-matching t) for more powerful matching (e.g., "reppdf" will match "report.pdf").

task keybinding ido function
completion TAB (ido-complete)
select RET  
exit ido-mode C-f (ido-fallback-command)
search for buffers C-b (ido-enter-buffer)
enter dired query C-d (ido-enter-dired)
edit matched text C-e (ido-edit-input)
commit to non-matching entry C-j (ido-select-text)
cycle forward C-s (ido-next-match)
cycle backward C-r (ido-prev-match)
kill file or buffer at head C-k  

python-mode

keybinding function
C-c ! (py-shell)
C-c C-l (py-shift-region-left)
C-c C-r (py-shift-region-right)
C-c C-p (py-execute-paragraph)
C-c (py-execute-region)
C-<return> (py-execute-region)

ess-mode

Can also invoke on a buffer with M-x r-mode.

keybinding function
C-c R (ess-start-R)
C-u C-c R (ess-start-R 'arg)
C-c C-j (ess-eval-line)
C-c C-n (ess-eval-line-and-step)
C-c C-r (ess-eval-region)
C-<enter> (ess-eval-region)
C-c C-p (ess-eval-paragraph-and-step)
C-c C-b (ess-eval-buffer)
C-c p (ess-op-fig)

tex-mode

keybinding function
C-c ] (LaTeX-close-environment)
C-c e (LaTeX-enclose-expression "$")
C-c j (LaTeX-insert-item-no-newline)
  • (LaTeX-close-environment) will complete the environment which is currently open with \end{environment}
  • (LaTeX-enclose-expression "$"): when invoked after a word or expression, this function will enclose the subscripted (_{}), superscripted (^{}), or keyword (\keyword) in $ $. This function can be invoked when a region is highlighted, in which case it will enclose the entire region, or with a prefix argument (C-u C-c e) enclose the entire word or connected expression (no space).
  • (LaTeX-insert-item-no-newline) inserts \item (followed by space) for use in a list environment (itemize, enumerate, list, etc.). For reference, the built-in function (LaTeX-insert-item) is invoked by C-c C-j.

Also, as stated earlier, C-c ; toggles comments in auctex (to uncomment region, also use C-c ; instead of C-u C-c ;.

It is often convenient to work alongside an emacs *shell* or *eshell* that can be used to compile the code after editing (there are additional keybindings provided by auctex for compilation and viewing, but this is an old-school approach). More information on running a shell provided in next section.

shell-mode

keybinding function
C-c p (copy-pwd)
C-c c (shell-mode-change-directory)
C-c d (dirs)
C-c l (clear-shell)

In both *shell* (M-x shell and C-u M-x shell to create more instances) or *eshell* (similarly, M-x eshell and C-u M-x eshell to create more instances), it is useful to be operating in the same directory as your script.

  • Split windows with C-x 2 (horizontal split) and C-x 3 (vertical split) and copy the paths of the shell or script with M-x copy-pwd (bound to C-c p; present working directory) and C-u M-x copy-pwd (C-u C-c p; present working directory of the other window) when necessary.
  • More useful: use C-c c to change the shell pwd to directory of other window (which is often the directory in which the script or tex file resides).
  • *shell* requires invocation of (dirs) to keep track of directories when aliases or shell variables are used to change paths.

elscreen

Sometimes when you resize the buffer with multiple screens, the buffer will flicker with certain keystrokes. Reset with C-z r.

If you want to manage many layouts through frames rather than screens, you can use the default frame keybindings, or cycle through them with C-c o (on a Mac, Command-` also works).

outline-minor-mode

Enabled for most major modes that we use.

keybinding function
M-[ a (show-all)
M-[ t (hide-body)
M-[ e (show-entry)
M-[ c (hide-entry)
M-[ s (show-subtree)
M-[ d (hide-subtree)

folding-mode

Enabled for most major modes that we use. In contrast to outline mode, I use this to hide "scratch" code I no longer need but don't want to delete or move to a separate scratch file.

keybinding function
M-] s (folding-show-current-entry)
M-] x (folding-hide-current-entry)
M-] t (folding-show-all)
M-] > (folding-shift-in)
M-] < (folding-shift-out)
  • (folding-shift-in) only shows only folded region, and (folding-shift-out) escapes back to view of main buffer.

unix (or unix-like) tools from the minibuffer

  • M-x rgrep
  • M-x find-lisp [ (require 'find-lisp) is found in aprl-misc-settings.el file]
  • M-x shell-command (also M-!)


Emacs pages: main aprl-config


Generated by Org-mode 9.2 with Emacs 26