Emacs Basics

C – ctrl

S – shift

M – Alt

RET – Enter

1.Set color scheme in emacs

Edit ~/.emacs and add below lines

(if (fboundp ‘global-font-lock-mode)
(global-font-lock-mode 1)        ; GNU Emacs
(setq font-lock-auto-fontify t))   ; XEmacs

2. open a file in emacs in terminal

emacs   <file-name>  -nw

3. close a file

C – x   C-c

4. save a file

C – x   C – s

5. delete a line

C – k

6. enable debug

M – x  pdb (for python) RET

7. quit debug

q

8.delete a window

C – x  0  (0 for current window, 1 – first, 2 – second etc )

9. Enable indentation for python

Edit ~/.emacs and add below line

;;; Ignoring electric indentation
(defun electric-indent-ignore-python (char)
“Ignore electric indentation for python-mode”
(if (equal major-mode ‘python-mode)
`no-indent’
nil))
(add-hook ‘electric-indent-functions ‘electric-indent-ignore-python)

;; Enter key executes newline-and-indent
(defun set-newline-and-indent ()
“Map the return key with `newline-and-indent'”
(local-set-key (kbd “RET”) ‘newline-and-indent))
(add-hook ‘python-mode-hook ‘set-newline-and-indent)

 

 

 

 

 

 

 

Leave a comment