If you prefer to use a single large emacs frame with multiple windows inside, you might like the golden ratio package. This automatically resizes your windows so that the window containing the point is the largest (size determined by the mathematical golden ratio). This means that the window you are working in is nice and large but you can still see what is going on in the other windows.
Install the package with the following:
First up, a reminder: in Emacs’ terminology the thing we usually call a window in other apps (the main display of an app with the menus etc at the top) is called a frame, and the individual panes within that (usually displaying different buffers side by side) are called windows.
Once you have been using Emacs for a while, you might find it more efficient to have a single large frame with several windows open inside displaying different buffers. It is then really easy to move between them using the built-in library
windmove by adding the following to your emacs config file:
;; :defer 4
;; use command key on Mac
;; wrap around at edges
(setq windmove-wrap-around t))
Now you can hold down the
super key (Command on a Mac) and press arrow keys to move to windows in any direction. Note that the default key is
shift plus arrow, but this conflicts rather painfully with org-mode, so I prefer super.
You can quickly sort tables in
org-mode by using
C-c ^ with the point inside a table. You’ll be prompted for a sorting type, where you can choose e.g.
a for alphabetic or
n for numeric. You can use capital letter versions of these options to reverse the sort.
The table is sorted based on the column that the point is in, and from the documentation:
The range of lines is the range between the nearest horizontal separator lines, or the entire table of no such lines exist.
I accidentally discovered that you can use
M-<right> to run the commands
mu4e-headers-query-next to quickly cycle through your previous queries. In mu4e this means this means previous searches but also different views like drafts and sent mail. Of course, this is in the manual but I had missed it before now.
I love the way that org-mode allows you to add simple clean structures to your text, with lists and tables. You can get some of that functionality in other modes by using
orgtbl-mode, which are part of
Enable these minor modes in any major mode for one-off use with
M-x orgstruct++-mode or
M-x orgtbl-mode and you can use the normal
org-mode commands to create lists and tables. I find this especially useful in emails, so I use this code in my emacs config file to automatically enable these for
;; use org structures and tables in message mode
(add-hook 'message-mode-hook 'turn-on-orgtbl)
(add-hook 'message-mode-hook 'turn-on-orgstruct++)
When you use one of Emacs’ help commands, another window will open with the documentation. You can use
C-M-V to scroll the other window down and up respectively to read the help, without having to switch to that window.
This is a bit of a niche post but I recently found I had accidentally started a bunch of duplicate timers all running the same function. I hadn’t recorded the timer objects for them so couldn’t use
cancel-timer to kill them. After a bit of searching I discovered the function
cancel-function-timers which will cancel all timers that call a particular function.
Not something you’ll be using every day, but might be useful one day!
*scratch* buffer is useful for dumping temporary bits of text, or trying out bits of lisp code. By default the contents are not saved, but it can be handy to have the scratch buffer saved and restored when you start a new Emacs session. This is easy with the persistent-scratch package, just add the following to your emacs config file:
This post was originally titled “Prevent Emacs wiping the system clipboard”, which was a rubbish description of what this tip actually covers, so I renamed it! Apologies if you see it twice in your RSS reader.
I wrote previously about adding mouse selections in Emacs to the system clipboard, and here is another tip to integrate the system clipboard more nicely with Emacs. This comes from the fantastic Emacs operating system set of configuration files, which are full of gems like this (thanks to Irreal for pointing me to EOS).
By default, if you copy something to the system clipboard (e.g. some text in firefox) and then copy or kill some text in Emacs, then the text from firefox is lost. If you set the option below in your emacs config file then copying or killing text in Emacs will add the system clipboard text to the kill-ring so that you can find it when you cycle through your clipboard history in Emacs.
;; Save whatever’s in the current (system) clipboard before
;; replacing it with the Emacs’ text.
(setq save-interprogram-paste-before-kill t)
I’ve written before about managing files in Emacs using dired. The package dired-ranger provides a useful extension to dired, allowing you to copy and paste files much like you can do in traditional GUI file explorers.
dired-ranger with something like the following
:bind (:map dired-mode-map
("W" . dired-ranger-copy)
("X" . dired-ranger-move)
("Y" . dired-ranger-paste)))
This also sets up some useful keybindings. Now in a dired buffer, you can mark multiple files and then hit
W to copy them (really they are added to a copy ring). You could then optionally go to another directory and mark more files and hit
C-u W to add those to the same entry in the copy ring as the previous files. This builds up a virtual collection of files that you can then copy or move. Now go to the target directory and hit
X to move the copied files to that directory (i.e. they are deleted from their original location) or
Y to copy the files to the target directory (the originals remain where they were).
You can achieve similar results using
dired-dwim-target or Sunrise Commander, but this method clicks with me and is the one that I use.