Skip to content
Madhu Srinivasan edited this page Jan 7, 2015 · 11 revisions

Snippets

ECB Layouts


Emacs and Shells


Scrolling inside emacs terminal

From http://stackoverflow.com/questions/5981151/how-to-scroll-up-in-emacs-ansi-term

In general, if you don't need full screen terminal emulation, shell-mode or eshell are better choices.

However, if you decide to stick with ansi-term, press C-c C-j to go into line mode. Then you can move around normally with the usual cursor movement keys. Press C-c C-k to get back into char mode to interact with the terminal.

Alternatively, you can scroll backwards a screen at a time with C-c C-v and just enter text to scroll back to the terminal input point.

Take a look at the Emacs documentation on term-mode (most of which applies equally to ansi-term) for more for more information.


ECB Keyboard Navigation

From http://stackoverflow.com/questions/4293554/in-ecb-in-emacs-how-can-i-switch-to-the-browser-window-using-the-keyboard

Keyboard navigation:

ECB windows from bottom to top.

  • Go to history: "C-c . g h"
  • Go to methods: "C-c . g m"
  • Go to sources: "C-c . g s"
  • Go to directories: "C-c . g d"

Main buffer: "C-c . g 1"


Customizing the size of ECB Frames

From http://stackoverflow.com/questions/4987760/how-to-change-size-of-split-screen-emacs-windows

With the mouse, you can drag the window sizes around.

Click anywhere on the mode line that is not otherwise 'active' (the buffer name is safe, or any unused area to the right hand side), and you can drag up or down.

Side-to-side dragging requires a very precise click on the spot where the two mode lines join.

C-x - (shrink-window-if-larger-than-buffer) will shrink a window to fit its content.

C-x + (balance-windows) will make windows the same heights and widths.

C-x ^ (enlarge-window) increases the height by 1 line, or the prefix arg value. A negative arg shrinks the window. e.g. C-- C-1 C-6 C-x ^ shrinks by 16 rows, as does C-u - 1 6 C-x ^.

(There is no default binding for shrink-window.)

C-x } (enlarge-window-horizontally) does likewise, horizontally.
C-x { (shrink-window-horizontally) is also bound by default.

Following one of these commands with repeat (C-x z to initiate, and just z for continued repetition) makes it pretty easy to get to the exact size you want.

If you regularly want to do this with a specific value, you could record a keyboard macro to do it, or use something like
(global-set-key (kbd "C-c v") (kbd "C-u - 1 6 C-x ^"))

Or this:
(global-set-key (kbd "C-c v") (kbd "C-x o C-x 2 C-x 0 C-u - 1 C-x o"))

Which is a smidgen hacky, so this would be better:

(defun halve-other-window-height ()
  "Expand current window to use half of the other window's lines."
  (interactive)
  (enlarge-window (/ (window-height (next-window)) 2)))

(global-set-key (kbd "C-c v") 'halve-other-window-height)

Tangentially, I also love winner-mode which lets you repeatedly 'undo' any changes to window configurations with C-c left (whether the change is the size/number/arrangement of the windows, or just which buffer is displayed). C-c right returns you to the most recent configuration. Set it globally with (winner-mode 1)