C-something = CTRL+something
M-something = ESC then something
C-x b : swith buffers
C-x o : other splitted window
C-SPACE : yank current line
C-w : delete selected block
M-x : grep
M-% : replace
C-g : quit all macro
C-x C-c : exit emacs
C-x C-f ~ : to know where is your .emacs
M-x whitespace-mode: show whitespaces and tabs:
Macros:
C-x ( start recording key strokes to build a keyboard macro.
C-x ) stop recording key strokes to for a keyboard macro.
C-x e execute the keyboard macro. Only one keyboard macro can be defined at a time. This is very powerful when used in conjunction with C-u
do for example: C-u 200 C-x e
;; show column numbers
(setq column-number-mode t)
(set-frame-font "DejaVu Sans Mono-8")
;; 1ASC-Liberation Mono-bold-normal-normal-*-*-*-*-*-m-0-iso10646-1
;; show matching parentesis when pressing % on a parenthesis
(global-set-key "%" 'match-paren)
(defun match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert %."
(interactive "p")
(cond ((looking-at "\\s(") (forward-list 1) (backward-char 1))
((looking-at "\\s)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))
(interactive)
(let ((b (if mark-active (min (point) (mark)) (point-min)))
(e (if mark-active (max (point) (mark)) (point-max))))
(shell-command-on-region b e
"python -mjson.tool" (current-buffer) t)))
Debugging C++ under emacs22
(setq column-number-mode t)
(set-frame-font "DejaVu Sans Mono-09")
(set-frame-font "DejaVu Sans Mono-8")
;; 1ASC-Liberation Mono-bold-normal-normal-*-*-*-*-*-m-0-iso10646-1
;; 2 spaces for tabs
(setq-default indent-tabs-mode nil);
(setq default-tab-width 2);
;; don't back up tilde files
(setq make-backup-files nil)
;; show column numbers
(setq column-number-mode t)
;; show matching parentesis when pressing % on a parenthesis
(global-set-key "%" 'match-paren)
(defun match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert %."
(interactive "p")
(cond ((looking-at "\\s(") (forward-list 1) (backward-char 1))
((looking-at "\\s)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))
json
(defun beautify-json ()(Just run M-x beautify-json on a buffer and it will reformat it)
(interactive)
(let ((b (if mark-active (min (point) (mark)) (point-min)))
(e (if mark-active (max (point) (mark)) (point-max))))
(shell-command-on-region b e
"python -mjson.tool" (current-buffer) t)))
to compile C++ using the F7 key
(global-set-key [f7] 'compile)
Vista
You cannot create a .emacs file simply on Vista (problem creating a file with a name starting with a dot). What I did is download one from the net.
- Replace in multiple files
- Call
dired
to list files in dir, or callfind-name-dired
if you need all subdirectories. (just select all files at this step "*") - Mark the files you want. You can mark all by doing CTRL G m m .You can mark by regex by typing 【% m】. (pom.xml for example)
- Type Q to call
dired-do-query-replace-regexp
. - Type your find regex and replace string. 〔➤ common elisp regex pattern〕
- For each occurrence, type y to replace, n to skip. Type 【Ctrl+g】 to abort the whole operation.
- Type ! to replace all occurrences in current file without asking, N to skip all possible replacement for rest of the current file. (N is emacs 23 only)
- To do the replacement on all files without further asking, type Y. (Emacs 23 only)
- Call
ibuffer
to list all opened files. - Type 【* u】 to mark all unsaved files, type S to save all marked files, type D to close them all.
- M-x gdb
Left click on the light gray column on the C++ source to set breakpoints (gdb needs to be running)
Use icons at the top as debugger commands.
.- I tried "ddd". It is on top of gdb. It is OK, but it is an external editor, independent of emacs. The ddd window is an XWindow but it is very close to what you get with gdb+emacs.
No comments:
Post a Comment