emacs memory dump
Q) How to search inside a file?
ctrl+s search will give a place to enter search term.
ctrl+s again to go to the next occurrence.
Q) How do I hide and show blocks of code?
ctrl+c h (ctrl c => custom key binding)
tab -> to hide one block
shit tab -> to hide all blocks
ctrl+s search will auto open and close blocks
To install this feature inside the .emacs file enter:
(add-to-list ‘load-path “~/.emacs.d”)
(add-hook ‘c-mode-common-hook ‘hs-minor-mode)
(add-hook ‘emacs-lisp-mode-hook ‘hs-minor-mode)
(add-hook ‘java-mode-hook ‘hs-minor-mode)
(add-hook ‘lisp-mode-hook ‘hs-minor-mode)
(add-hook ‘perl-mode-hook ‘hs-minor-mode)
(add-hook ‘sh-mode-hook ‘hs-minor-mode)
(add-hook ‘R-mode-hook ‘hs-minor-mode)
(global-set-key “\C-ch” ‘hs-org/minor-mode)
(require ‘hideshow-org)
Inside .emacs.d put the file hideshow-org.el
Q) How do I indent the code?
ctrl x h -> to mark all the content
meta x indent-region to indent the content
Q) How do I get a list of files on a panel on the right?
sr-speedbar to get a file list as a panel on the right
https://raw.github.com/emacsmirror/sr-speedbar/master/sr-speedbar.el
In the .emacs file add:
(add-to-list ‘load-path “~/.emacs.d”)
(package-initialize)
(load “~/.emacs.d/sr-speedbar.el”)
Q) How to get to lisp eval prompt?
meta : will give the lisp eval prompt
Q) How do I do addition on the eval prompt?
ctrl +x ctrl + e will evaluate the expression on that line
So I can write
(+2 1)
and then do:
ctrl+x ctrl+e to get the eval at the bottom region.
Q) What other eval commands can I use?
eval region
eval buffer
Q) How to make navigating files easier?
ido-mode -> helps in navigation trees and long file names.
In the .emacs file enter:
(ido-mode 1)
(ido-better-flex/enable)
Q) Since ido takes over the enter key to enter a directory how do I open a directory?
ctrl + j -> represents enter anywhere in terminal
Q) What commands will emacs take in dired mode?
shift+d to delete
+ to create dir
Q) How to enable a package repo in emacs?
(require ‘package)
(add-to-list ‘package-archives
‘(“marmalade” .
“http://marmalade-repo.org/packages/”))
Now you can give the command:
meta x package-install
Q) How to go to a specific line?
alt g g
Q) How to exit out of a command?
ctrl + g
Q) How to cut and paste?
cut -> ctrl + k
paste -> ctrl + y
mark -> ctrl + space
move around to a place and stop will give a point
between mark and point is the region
ctrl+w to cut the region
alt+w to copy the region
ctrl+y to paste (yank)
alt+y right after the above command to go to the previous content in the right buffer.
Q) How to do search and replace?
meta % => go to query replace
! to replace all
Q) How to access the history?
meta p -> history depending on context
meta n -> next statement in history depending on context.
Q) How to open the shell ?
meta x eshell (stands for emacs shell)
meta x ansi-term
Q) How to create multiple windows ?
ctrl+x 2 -> horizontal split
ctrl+x 3 -> vertical split
ctrl+x o -> to move around windows.
Q) What are some useful commands to move the cursor around?
Begin line C-a
End line C-e
Down line C-n
Up line C-p
Scroll down C-v
Scroll up M-v
Q) How do I get pretty syntactic highlighting for my code?
M-x font-lock-mode
Q) How to get help?
describe function: ctrl+h f -> this will allow to enter a function name
describe key: ctrl+h k
Q) What are some good videos to watch?
https://www.youtube.com/user/rpdillon?feature=watch






