|
Main / Emacs
ctrl x, ctrl f = open ctrl x, arrow = switch buffer crtl x, ctrl e = evaluate expression on the line (must highlight entire expression) ctrl x, h = select all ctrl c, ctrl f = copy file path to clipboard (not the primary selection) ctrl s = search ctrl x, tab = block indent interactive (follow with arrow key control) ctrl h, k = describe key alt x, hexl-find-file = lets you open a binary file in hex format Accessing complex instructionsalt x, recover-file = restore auto-save file (#filename#.ext) ConfigTo diagnose problems with the config file run with --debug-init To add an emacs plug-in, download the .el file and place into ~/.emacs.d/ Then add these lines to .emacs (add-to-list 'load-path "~/.emacs.d/") (load "myplugin.el") (require 'myplugin) Features of my config file:ctrl ; = block comment I have included ibuffer which is an add-on improvement over the standard buffer listings. Other hints about buffers How to assign syntax highlighting to an unrecognized file extensionhttp://unix.stackexchange.com/questions/25184/emacs-file-extension-recognition Font face manipulationalt-o, d Remove all face properties (facemenu-set-default). Why are my makefile comments highlighted?The indented ones are because they are passed by make to the shell as commands and are not interpreted immediately as comments. Link Highlightinghttps://emacs.stackexchange.com/questions/4001/saving-and-restoring-highlighting-patterns File Mode Editsctrl-h, v major-mode For shell scripts, Source Tagging for Reference LinkingCscopeInstall Cscope and the Emacs lisp extension with sudo apt install cscope cscope-el. cscope -R at top level will generate the database and launch the UI. etagsThis will take in all the .c/.h/.cpp/.hpp files in the tree where executed and generate a TAGS file: find . -type f -regex ".*\.*[ch]\(pp\)?$" | etags - alt . = find definition The first time you try to use it, Emacs will ask where the TAGS file is location. After that you should be fine. Update NotesApparently pc-selection-mode is obsoleted and replaced with delete-selection-mode List of Emacs optionshttps://docstrings.github.io/list.html .emacs file
(message "* --[ Loading my Emacs init file ]--")
(message "* --[ * Created by TSheffield * ]--")
(message "* --[ Note: requires plug-ins ]--")
(defun c-mode-common-hook ()
(c-toggle-electric-state -1)
(c-set-style "k&r")
)
;;(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;; make vertical buffer split the default if applied
(setq split-width-threshold 1)
;;add disaster.el disassembly viewer, uses ctrl-shift-d
(add-to-list 'load-path "/home/ts/.emacs.d/addons")
(require 'disaster)
(global-unset-key (kbd "C-S-d"))
(global-set-key (kbd "C-S-d") 'disaster)
;;(define-key c-mode-map (kbd "C-c d") 'disaster)
;; shows cursor column num after line (line#,col#)
(setq column-number-mode t)
;; disable C-z kill and set to undo
(global-set-key "\C-Z" nil)
(global-set-key "\C-Z" 'undo)
;; enable clipboard share
(setq x-select-enable-clipboard t)
;; set colors
(set-background-color "#2f2f2f")
(set-foreground-color "white")
;; set indent
;;(setq-default standard-indent 3)
;; turns off tabs for indentation
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
;;(setq tab-width 3)
(defvaralias 'c-basic-offset 'tab-width)
(setq tab-stop-list (number-sequence 4 120 4))
;;(setq tab-stop-list (number-sequence 8 120 8))
;; If you wish to change the amount of spaces that the Tab key inserts, check out the
;; TabStopList page. Do not confuse this with tab-width, which is only good for displaying
;; existing tabs in files!
;; set shell script mode indentation default (2 is for HR coding style)
(setq-default sh-indentation 2)
;; none of this crap works, emacs ignores it
(setq-default sh-indent-after-continuation nil)
(setq-default sh-indent-for-continuation 0)
;; line highlighting
;;(defvar running-xemacs (string-match "XEmacs" emacs-version))
;;(if (not running-xemacs)
;;(pc-selection-mode 1))
;; add block comment capability
(global-set-key (kbd "C-;") 'comment-region)
(global-set-key (kbd "C-'") 'uncomment-region)
;; show file path
(setq frame-title-format
(list (format "%s %%S: %%j " (system-name))
'(buffer-file-name "%f" (dired-directory dired-directory "%b"))))
;; make Completions buffer disappear for good
(add-hook 'minibuffer-exit-hook
'(lambda ()
(let ((buffer "*Completions*"))
(and (get-buffer buffer)
(kill-buffer buffer)))))
;; view scons files in Python mode
(setq auto-mode-alist
(cons '("SConstruct" . python-mode) auto-mode-alist))
(setq auto-mode-alist
(cons '("SConscript" . python-mode) auto-mode-alist))
;; use the ibuffer add-on
(require 'ibuffer)
;(global-set-key (kbd "C-x C-b") 'ibuffer-other-window) - opens in split
;(global-set-key (kbd "C-x C-b") 'buffer-menu) - opens emacs default buffer list
(global-set-key (kbd "C-x C-b") 'ibuffer)
(setq ibuffer-default-sorting-mode 'alphabetic)
;; try buffer stack add-on (MUST first download buffer-stack.el and place into .emacs.d/addons)
(require 'cl)
(add-to-list 'load-path "~/.emacs.d/addons")
(load "buffer-stack.el")
(require 'buffer-stack)
(global-set-key [(f5)] 'buffer-stack-rebuild )
(global-set-key [(f9)] 'buffer-stack-bury)
(global-set-key [(control f9)] 'buffer-stack-bury-and-kill)
(global-set-key [(f10)] 'buffer-stack-up)
(global-set-key [(f11)] 'buffer-stack-down)
(global-set-key [(f12)] 'buffer-stack-track)
(global-set-key [(control f12)] 'buffer-stack-untrack)
;; fix next and prev buffer commands
(global-set-key (kbd "M-<right>") 'next-buffer)
(global-set-key (kbd "M-<left>") 'previous-buffer)
;; be rid of useless buffers and stop split screen on init
(setq inhibit-startup-screen t)
(custom-set-variables '(inhibit-startup-screen t) )
(add-hook 'emacs-startup-hook
(lambda () (delete-other-windows)) t)
(kill-buffer "*scratch*")
;; work on sorting buffer list goes here
(defun reorder-buffer-list (new-list)
(while new-list
(bury-buffer (car new-list))
(setq new-list (cdr new-list))
)
)
;; buffer name sort idea from https://www.emacswiki.org/emacs/BufferMenuSorting
(defun sort-buffers ()
"Put the buffer list in alphabetical order."
(interactive)
(dolist (buff (buffer-list-sorted)) (bury-buffer buff))
(when (interactive-p) (list-buffers))
)
(defun buffer-list-sorted ()
(sort (buffer-list)
(function
(lambda
(a b) (string<
(downcase (buffer-name a))
(downcase (buffer-name b))
)))))
(global-set-key "\M-b" 'sort-buffers)
;; set up backtab
(global-set-key (kbd "<backtab>") 'un-indent-by-removing-4-spaces)
(defun un-indent-by-removing-4-spaces ()
"remove 4 spaces from beginning of of line"
(interactive)
(save-excursion
(save-match-data
(beginning-of-line)
;; get rid of tabs at beginning of line
(when (looking-at "^\\s-+")
(untabify (match-beginning 0) (match-end 0)))
(when (looking-at "^ ")
(replace-match ""))
(when (looking-at "^ ")
(replace-match ""))
(when (looking-at "^ ")
(replace-match "")))))
;; set up block tab
(global-set-key [C-tab] 'indent-for-tab-command)
;; set word wrap style as default
(global-visual-line-mode t)
;; stop creating ~ backup files
(setq make-backup-files nil)
;; set default font and size
(set-frame-font "Ubuntu Mono 11" nil t)
;;(print (font-family-list))
;; highlight web links in text
(defun do-web-highlight ()
(highlight-phrase "http:.*" 'hi-blue)
(highlight-phrase "https:.*" 'hi-blue)
)
(add-hook 'find-file-hook 'do-web-highlight)
;;add keys to scroll window up/down by one line
(global-set-key (kbd "M-<down>") (kbd "C-u 1 C-v"))
(global-set-key (kbd "M-<up>") (kbd "C-u 1 M-v"))
;; no line wrap
(global-visual-line-mode -1)
(setq-default word-wrap nil)
(setq-default truncate-lines t)
|