Chinaunix首页 | 论坛 | 博客
  • 博客访问: 135826
  • 博文数量: 51
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 540
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-21 12:33
文章分类

全部博文(51)

文章存档

2011年(1)

2010年(5)

2009年(1)

2008年(12)

2007年(32)

我的朋友

分类: LINUX

2007-07-21 15:08:25

Emacs is a very powerful editor. It's extensible, customizable by editting .emacs file. I will list the functions which I often use.

Emacs Basic command

Emacs Files, Exiting

  - emacs filename 
    start Emacs from terminal with file filename. 
  - emacs +n filename 
    start Emacs from terminal at line n of filename. 
  - C-x C-f filename/dirname 
    find (open) file filename/dirname. 
  - C-x 4 C-f filename 
    find (open) file filename in new window. 
  - C-x C-r filename 
    read file filename to active buffer. 
  - C-x i RET filename 
    insert file filename into buffer. 
  - C-x C-s 
    save file from active window (buffer). 
  - C-x s 
    save some file from inactive window (buffer). 
  - C-x C-w filename 
    write active buffer into file filename. 
  - C-x C-c 
    exit Emacs with queries. 

Emacs Buffers

  - C-x C-b 
    List BUFFERS, then 1 selects highlighted buffer. 
  - C-x b buffername 
    switch to buffername. 
  - C-x 4 b buffername 
    switch to buffername in separate window. 
  - C-x k 
    kill active buffer. 
  - C-x C-v 
    kill active buffer, find alternative. 

Emacs Windows

  - C-x 2 
    split display into 2 horizontal windows. 
  - C-x 3 
    split display into 2 vertical windows. 
  - C-x 1 
    collapse display into one window. 
  - C-x 0 
    kill (zero) inactive window. 
  - C-x o 
    make other window active. 
  - C-x p 
    make previous window active. 
  - C-x ^ 
    open active vertical window higher. 
  - C-x } 
    open active horizontal window wider. 

Emacs Movement

  - C-f 
    forward a character. 
  - C-b 
    backward a character. 
  - C-n 
    next line. 
  - C-p 
    previous line. 
  - M-f 
    forward a word. 
  - M-b 
    backward a word. 
  - C-a 
    beginning of line. 
  - C-e 
    end of line. 
  - M-a 
    beginning of sentence. 
  - M-n 
    beginning of paragraph. 
  - M-p 
    end of paragraph. 
  - M-99 C-l 
    line 99. 
  - M-99 
    enter 99 as argument. 
  - M-x goto-line RET 99 
    line 99. 
  - M-x goto-char RET x 
    character x. 
  - M-< 
    beginning of file. 
  - M-> 
    end of file. 
  - C-v 
    forward 1 screen. 
  - M-v 
    backward 1 screen. 
  - C-M-v 
    Forward in inactive window. 
  - C-l 
    recenter (cursor on same character). 
  - M-l(downcase-word)
    change next word to lowercase. 
  - M-x upcase-word
    change next word to uppercase. 

Emacs Position

  - M-x what-page 
    print page and line number of point. 
  - M-x what-line 
    show what line cursor is on. 

Emacs Mark and Region

  - C- (or C-@) 
    set mark at cursor. 
  - C-x C-x 
    exchange mark and cursor. 
  - C-w 
    cut region to clipboard. 
  - M-w 
    copy region to clipboard; no delete. 
  - C-x  
    indent region. 

Emacs search and replace

  - C-s word 
    incremental search forward for word
  - C-s 
    continue SEARCH forward. 
  - C-r word
    reverse search for word. 
  - C-r
    reverse search. 
  - M-x occur RET expression 
    list all occurrences of expression, cursor on line 
    in occur-buffer, ^ c ^ c to find. 
  - M-% 
    synonym for ~ x query-replace. 
  - M-x replace-string RET old RET new 
    replace all old with new. 
  - M-x query-replace RET old RET new 
    replace after query oldwith new, Emacs asks. 

Emacs cut and paste

  - C-k 
    kill & store from cursor to end of line. 
  - M-k 
    kill to end of sentence; stored on clipboard. 
  - C-w 
    cut region stored on clipboard. 
  - M-w 
    copy region to clipboard. 
  - M-C-w 
    append kill to previous kill on clipboard. 
  - C-y 
    paste (yank) text of last kill (from clipboard). 
  - M-y 
    Paste (yank) text of previous kill. 

Emacs word processing

  - M-q 
    fill paragraph containing cursor. 
  - M-g 
    fill region (mark - cursor). 
  - M-1 M-q 
    Fill and right justify paragraph. 
  - C-o (oh) 
    open a blank line here. 
  - M-u 
    uppercase next word. 
  - M-l 
    lowercase next word. 
  - M-c 
    capitalize next word. 
  - C-x C-u 
    uppercase region. 
  - C-x C-l 
    lowercase region. 
  - C-t 
    transpose letters. 
  - M-t 
    transpose words. 
  - C-x TAB 
    indent region. 
  - M-$ 
    spellcheck last word. 
  - M-x spell-buffer 
    spellcheck buffer. 
  - M-x spell-region 
    spellcheck region. 

Emacs undo and help

  - C-g
    abort command in process.
  - C-x u
    undo last command (repeatable). 
  - C-h w 
    find the key for a command
  - C-h k 
    find the command for a key
  - C-h C-f 
    get the description of a command
  - C-h a 
    select you wanted command that matched regexp
  - C-h b 
    see key bindings
  - C-h ? 
    get all the command list
  - C-h v 
    check the value of a variable

Emacs Regular Expression

- *
	Repeats the previous regular expression 
   any number of times (including zero times).

- +
  Repeats the previous regular expression 
  any number of times (at least one time).

- ?
  The previous regular expression matches 
  zero or one time.

- .
  Matches any character.

- \(...\)
	
  Groups the text for later reference 
  or to overcome precedence problems.

- [...]
  Matches any of the characters within the group. 
  Note that the usual regexp special characters are not special
  inside a character set. - [^...] Matches any character not in this group. - ^ Matches the beginning of the line or string. - $ Matches the end of line or string. - \< Matches the beginning of a word. - \> Matches the end of a word. Ex: 1. 1.c 2.c 3.c ... replace with 1.java 2.java 3.java ... M-x query-replace-regexp \([0-9]*\)\.c with \1.java 2. if you want to add " at the beginning, ", at the end M-x query-replace-regexp ^\(.*\)$ with "\1", 3. #define CCE_CONCFM 1 /* Connct confirm */ #define CCE_ADDRIND 2 /* Address Indication */ #define CCE_CNSTIND 3 /* Connection progress status indication */ #define CCE_RELIND 4 /* Connection release indication */ #define CCE_RELCFM 5 /* Connection release confirmation */ #define CCE_RSCCFM 6 /* Resouce Confirm */ #define CCE_REATIND 7 /* Status Indication - Reattempt */ only left CCE_CONFM M-x query-replace-regexp ^#[^ ]* *\([^ ]*\) *.* with \1

Hex Editor

- M-x hexl-mode
  all in current buffer will display in  Hex Mode.

- C-M-d
  Insert a byte with a code typed in decimal.

- C-M-o
  Insert a byte with a code typed in octal.

- C-M-x
  Insert a byte with a code typed in hex.

- C-x [
  Move to the beginning of a 1k-byte "page."

- C-x ]
  Move to the end of a 1k-byte "page.

- M-g
  Move to an address specified in hex.

- M-j
  Move to an address specified in decimal.

- C-c C-c
  Leave Hexl mode

Programming & Debugging

- M-x compile 
  if Makefile exists, you can run make or you can run gcc command.

- M-x gdb 
  run the GUD debugger, execute  gdb (or dbx ) command. An arrow 
  will indicate the execution line

Emacs + cscope

Build cscope datebase

- find . -name *.[chly] > cscope.files
- cscope -b -q -k
 

using cscope in Emacs

- install cscope add the following to .emacs
  (require 'xcscope)

- C-c s s         Find symbol.
- C-c s d         Find global definition.
- C-c s g         Find global definition (alternate binding).
- C-c s G         Find global definition without prompting.
- C-c s c         Find functions calling a function.
- C-c s C         Find called functions.
- C-c s t         Find text string.
- C-c s e         Find egrep pattern.
- C-c s f         Find a file.
- C-c s i         Find files #including a file.
- C-c s b         Display *cscope* buffer.
- C-c s B         Auto display *cscope* buffer toggle.
- C-c s n         Next symbol.
- C-c s N         Next file.
- C-c s p         Previous symbol.
- C-c s P         Previous file.
- C-c s u         Pop mark.

using vi in Emacs

- M-x viper-mode

using eshell

- M-x eshell

using ediff

start ediff

- M-x ediff

note: M-x ediff-toggle-multiframe
      M-x ediff
      use ediff in multiframe mode.

ediff commands

- ediff-buffers
  Compare two buffers

- ediff-files3
  Compare three files

- ediff-buffers3
  Compare three buffers

- ediff-directories
  Compare files common to two directories.

- wa
  Saves buffer A, if it was modified.

- wb
  Saves buffer B, if it was modified.

- a
  Copies the current difference region from buffer A to buffer B. 

- b
  copies the current difference region from buffer B to buffer A 

- p
  Makes the previous difference region current

- n
  Makes the next difference region current

- ra
  Restores the old contents of the current difference region in buffer A

- rb
  Restores the old contents of the current difference region in buffer B

using etags

- etags *.h *.cpp                  create TAGS Table
- M-x visit-tags-table               load TAGS Table
- M-. TAGNAME                        Find TAGNAME
- M-*                                return back

using bookmarks

- C-x r m               set bookmark at the current point
- C-x r m BOOKMARK      set bookmark named BOOKMARK
- C-x r b BOOKMARK      jump to BOOKMARK
- C-x r l               list all bookmarks
- M-x bookmark-save     save all book marks in default file
- M-x bookmark-load     load book marks file
- M-x bookmark-write    write book marks file
- M-x bookmark-delete   delete book marks file

using ebrowse

- ebrowse *.h *.cpp      default generate BROWSE file
- c-x c-f BROWSE           load a class tree
- x                        display statistic
- +                        expand a class
- -                        collapse a class
- T f                      display the file name
- L f                      list all the function of a class

using setnu

- Download setnu.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs
     (require 'setnu)

- M-x setnu-mode
  The line number will display at the beginning of the line

using browse-kill-ring

- Download browse-kill-ring.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs
     (require 'browse-kill-ring)
     (global-set-key [(control c)(k)] 'browse-kill-ring)
     (browse-kill-ring-default-keybindings) 

- M-x browse-kill-ring (or C-c k)
  Display the kill ring  

using hide-lines

- Download hide-lines.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs
     (require 'hide-lines)
     (global-set-key (kbd "C-c l") 'hide-lines)
     (global-set-key (kbd "C-c L") 'show-all-invisible)

- M-x hide-lines (or C-c l)
  Hide the lines matching REGEXP
- M-x show-all-invisible(or C-c L)
  Show all the lines hidden 

using hide-region

- Download hide-region.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs
     (require 'hide-region)
     (global-set-key (kbd "C-c r") 'hide-region-hide)
     (global-set-key (kbd "C-c R") 'hide-region-unhide)

- M-x hide-region (or C-c r)
  Hide the region
- M-x hide-region-unhide(or C-c L)
  unhide the region

using auto-fill mode

  - M-x auto-fill-mode
    Enable or disable Auto Fill mode

  - C-x f (set-fill-column)
    Set the fill column(C-u 70 C-x f)

  - C-x . (set-fill-prefix)
    Set the fill prefix

  - M-q (fill-paragraph)
    Fill a paragraph using current fill prefix
 

using table

- Download table.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs
     (require 'table)

- Oprerations on table
  - M-x table-insert
    insert a table at the current point.
  - C->
    widen the current cell
  - C-< 
    narrow the current cell
  - C-} 
    Heighten the current cell
  - C-{ 
    Widen the current cell
  - C-+ 
    insert row or columns
  - table-delete-row
    delete the current row
  - table-delete-column
    delete the current column
  - table-forward-cell
    move the cursor to the next cell
  - table-backward-cell
    move the cursor to the next cell

Using rect-mark

- Download rect-mark.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs

     (require 'rect-mark)

     (define-key ctl-x-map "r\C-@" 'rm-set-mark)
     (define-key ctl-x-map [?r ?\C-\ ] 'rm-set-mark)
     (define-key ctl-x-map "r\C-x" 'rm-exchange-point-and-mark)
     (define-key ctl-x-map "r\C-w" 'rm-kill-region)
     (define-key ctl-x-map "r\M-w" 'rm-kill-ring-save)
     (define-key global-map [S-down-mouse-1] 'rm-mouse-drag-region)

- Operations on a rect

  - C-x r C-@ 
    set the rect mark
  - C-x r C-w
    cut the selected rect
  - C-x r M-w 
    copy the selected rect

using tabbar

- Download tabbar.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs
     (require 'tabbar)
     (tabbar-mode)

- define the key to switch tab in .emacs

   (global-set-key [C-down] 'tabbar-backward-group)
   (global-set-key [C-up]  'tabbar-forward-group)
   (global-set-key  [C-left] 'tabbar-backward)
   (global-set-key  [C-right] 'tabbar-forward)

using ibuffer

- Download ibuffer.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs
     (require 'ibuffer)
     (tabbar-mode)

- Operations on marked buffers

  - S 
    Save the marked buffers.
  - v
    View the marked buffers in this frame.
  - H 
    View the marked buffers in another frame.
  - D 
    Kill the marked buffers.
  - U 
    Replace by regexp in each of the marked buffers.
  - Q
    Query replace in each of the marked buffers.
  - P 
    Print the marked buffers.
  - O 
    List lines in all marked buffers which match
    a given regexp (like the function `occur').
  - X 
    Run a shell command on the contents of marked buffers.
  - N
    Replace the contents of the marked
    buffers with the output of a shell command.
  -x 
    Kill all buffers marked for deletion.
  -m 
    Mark the buffer at point.
  -t
    Unmark all currently marked buffers, and mark
    all unmarked buffers.
  -u 
    Unmark the buffer at point.
  - * * 
    Unmark all marked buffers.
  - d 
    Mark the buffer at point for deletion.
  - % n 
    Mark buffers by their name, using a regexp.
  - % m 
    Mark buffers by their major mode, using a regexp.
  - % f 
    Mark buffers by their filename, using a regexp.
  - = 
    View the differences between this buffer
    and its associated file.
  - f 
    View the buffer on this line.
  - o 
    As above, but in another window.
    

using table

- Download table.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs
     (require 'table)

- Oprerations on table

  - M-x table-insert
    insert a table at the current point.
  - C->
    widen the current cell
  - C-< 
    narrow the current cell
  - C-} 
    Heighten the current cell
  - C-{ 
    Widen the current cell
  - C-+ 
    insert row or columns
  - table-delete-row
    delete the current row
  - table-delete-column
    delete the current column
  - table-forward-cell
    move the cursor to the next cell
  - table-backward-cell
    move the cursor to the next cell

Using Dired

- Oprations on Files or Directories

  - M-x dired(C-x d)
    start dired(manage files in current directory)
  - C-n, C-p
    put the cursor to next(or prev) file name
  - d
    Flag this file for deletion(mark with D )
  - u
    Remove deletion flag on this line
  - x
    Delete the files that are flagged for deletion
  - #
    Flag all auto-save files ( #FILENAME# )
  - ~
    Flag all backup files ( FILENAME~ )
  - %d REGEXP
    Flag for deletion all files whose names match REGEXP
  - f
    Visit the file described on the current line
  - v 
    View the file described on the current line
  - ^
    Visit the parent directory of the current directory
  - m
    Mark the current file with *
  - u
    Remove any mark on this line
  - * *
    Mark all executable files with *
  - * @
    Mark all symbolic links with *
  - * /
    Mark directories with * except . and  ..
  - * s
    Mark all the files in the current subdirectory. except . and ..
  - * !
    remove all marks.
  - % m REGEXP ( * % REGEXP )
    Mark all files whose names match REGEXP
  - C NEW
    Copy the specified files. The variable dired-recursive-copies
    controls whether directories are copied recursively. NEW 
    is directory or a specific file.
  - D
    Delete the specified files
  - R NEW
    Rename the specified files
  - H NEW
    Make hard links to the specified files
  - S NEW
    Make symbolic links to the specified files
  - M MODESPEC
    Change the mode of the specified files
  - G NEWGROUP
    Change the group of the specified files to NEWGROUP
  - P COMMAND
    Print the specified files
  - Z 
    Compress the specified files
  - L
    Load the specified Emacs Lisp files
  - B
    Byte compile the specified Emacs Lisp files
  - A REGEXP
    Search all the specified files for REGEXP
  - Q REGEXP  TO 
    Perform query-replace-regexp on each of the specified files
  - !
    runs that shell command in the minibuffer on all the specified files
  - % u
    Rename each of the selected files to an upper-case name
  - % l
    Rename each of the selected files to a lower-case name
  - % R(C, H, S) FROM  TO 
    rename, copy, make hard links soft links, computing the 
    new name by REXEXP from the old name
  - =
    Compare the current file with another file
  - M-=
    Compare the current file with its latest backup file
  - >
    Move to the next directory
  - <
    Move to the prev directory
  - $
    Hide or reveal the current subdirectory
  - M-$
    Hide all subdirectories in this Dired buffer
  - g
    Update the entire contents of the Dired buffer
  - l
    Update the specified files
  - M-x find-name-dired
    search for files with names matching a wildcard pattern
  - M-x find-grep-dired
    chooses all the files in DIRECTOR that contain a match 
    for REGEXP
  - M-x find-dired
    lets you specify any condition that **find** can test

Using emacs-wiki

- Download emacs-wiki.el, emacs-wiki-menu.el, emacs-wiki-srctag,
  emacs-wiki-table.el and install it.
  
  1. place them under /usr/share/emacs/site-lisp

  2. Add the following to .emacs

     (require 'emacs-wiki)
     (require 'emacs-wiki-menu)
     (require 'emacs-wiki-srctag)
     (require 'emacs-wiki-table)   

     (add-hook 'emacs-wiki-mode-hook
	    (lambda ()
	    (define-key emacs-wiki-mode-map (kbd "C-c C-h") 'emacs-wiki-preview-html)
	    (define-key emacs-wiki-mode-map (kbd "C-c C-c") 'emacs-wiki-preview-source)
	    (define-key emacs-wiki-mode-map (kbd "C-c C-v") 'emacs-wiki-change-project)

     ))

     (setq emacs-wiki-publishing-directory "~/public_html")

      (setq emacs-wiki-style-sheet "")
      '(emacs-wiki-mode-hook (quote (emacs-wiki-use-font-lock flyspell-mode footnote-mode)))

      (setq emacs-wiki-inline-relative-to 'emacs-wiki-directories)

      (defun emacs-wiki-preview-source ()
        (interactive)
        (emacs-wiki-publish-this-page)
        (find-file (emacs-wiki-published-file)))

      (defun emacs-wiki-preview-html ()
        (interactive)
        (emacs-wiki-publish-this-page)
        (browse-url (emacs-wiki-published-file)))

      (setq emacs-wiki-projects
        `(("default" . ((emacs-wiki-directories . ("~/wiki/"))))
         ("work" . ((fill-column . 65)
         (emacs-wiki-directories . ("~/wiki/read/"))))))

- Operations that emacs-wiki often used

  - M-x emacs-wiki-find-file
    find a file to edit using emacs-wiki
  - C-c C-a    
    jump to an index of all the Wiki pages
  - C-c C-b    
    show all pages that reference this page
  - C-c C-s    
    search for a word in your Wiki pages
  - C-c C-f    
    jump to another Wiki page; prompts for the name
  - C-c C-l    
    highlight/refresh the current buffer
  - C-c C-p    
    publish any Wiki pages that have changed as HTML
  - C-c C-r    
    rename wiki link at point
  - C-c C-v    
    change wiki project
  - C-c C-D    
    delete wiki link at point (binding will only work on X)
  - C-c =      
    diff this page against the last backup version
  - TAB        
    move to the next Wiki reference
  - S-TAB      
    move to the previous Wiki reference
 

Using folding

- Download folding.el and install it.
  
  1. place it under /usr/share/emacs/site-lisp

  2. Add the following to .emacs

      (autoload 'folding-mode "folding"
        "Minor mode that simulates a folding editor" t)
      
      (autoload 'turn-off-folding-mode "folding" "Folding mode" t)
      
      (autoload 'turn-on-folding-mode  "folding" "Folding mode" t)
      
      
      
      (defun folding-mode-find-file-hook ()
         "One of the hooks called whenever a `find-file' is successful."
         (and (assq 'folded-file (buffer-local-variables))
              folded-file
              (folding-mode 1)
              (kill-local-variable 'folded-file)))
      
      (load-library  "folding")
      (declare (special fold-fold-on-startup
      		  fold-keys-already-setup
      		  ))
          
      (setq fold-fold-on-startup t)
      (folding-mode-add-find-file-hook)
      
      (setq fold-keys-already-setup nil)
      (add-hook 'folding-mode-hook
      	  (function (lambda()
      		      (unless fold-keys-already-setup
      			(setq fold-keys-already-setup t)
      			(define-prefix-command 'ctl-t-folding-mode-prefix)
      			(define-key 'ctl-t-folding-mode-prefix "f" 'fold-fold-region)
      			(define-key  'ctl-t-folding-mode-prefix "e" 'fold-enter)
      			(define-key 'ctl-t-folding-mode-prefix "x" 'fold-exit)
      			(define-key  'ctl-t-folding-mode-prefix "b" 'fold-whole-buffer)
      			(define-key 'ctl-t-folding-mode-prefix "o" 'fold-open-buffer)
      			(define-key 'ctl-t-folding-mode-prefix "h" 'fold-hide)
      			(define-key 'ctl-t-folding-mode-prefix "s" 'fold-show)
      			(define-key 'ctl-t-folding-mode-prefix "t" 'fold-top-level)
      			(define-key 'ctl-t-folding-mode-prefix "f" 'fold-fold-region)
      			)
      		    (local-set-key "\C-f" 'ctl-t-folding-mode-prefix))))
      
      (fold-add-to-marks-list 'sgml-mode
      			"" " --> ")
      (fold-add-to-marks-list 'c-mode "/* <" "/* > */" "*/")
      (fold-add-to-marks-list 'c++-mode
      			"//<" "//>" "")
      (fold-add-to-marks-list 'LaTeX-mode "%%% {{{" "%%% }}}" " ")
      (fold-add-to-marks-list 'latex2e-mode "%%% {{{" "%%% }}}" " ")
      (fold-add-to-marks-list 'latex-mode "%%%% {{{" "%%%% }}}" " ")
      (fold-add-to-marks-list 'BibTeX-mode "%%% {{{" "%%% }}}" " ")
      (fold-add-to-marks-list 'lisp-mode ";;; {" ";;; }" "")
      (fold-add-to-marks-list 'lex-mode" /* {{{ " " /* }}} */ " "*/")
      (fold-add-to-marks-list 'html-mode "" "-->")
      (fold-add-to-marks-list 'shell-script-mode "# {{{" "# }}}" nil)
      (fold-add-to-marks-list 'sh-mode "# {{{ " "# }}}" nil)
      

- Operations

   - M-x folding-mode
     start folding mode
   - C-@ 
     define a mark, then move the cursor to define a region.
   - C-f f
     fold this region
   - C-f x
     exit this fold
   - C-f e
     enter this fold
   - C-f h
     hide this fold
   - C-f s
     Show this fold
  

Using PCL-CVS

Entering PCL-CVS

- get a source code copy in terminal
  
  cvs checkout MODULE

- M-x cvs-examine

  invoke PCL-CVS, create a *cvs* buffer
  will run cvs update

Operation on cvs buffer

- n, p, C-n, C-p
  move the cursor
- f, o, RET
  open the current file
- l
  display log information
- s
  show status info in *cvs-info* buffer
- z, q
  close the *cvs* buffer
- a
  add selected files, need commit
- r
  delete selected files, need commit
- M-s
  display all file status
- M-u
  run cvs update
- M-e 
  run cvs examine
- m
  mark a file
- u
  unmark a file
- %
  mark a file according to REGEXP
- t
  set tag name
- x
  remove all 'up-to-date' file in *cvs* buffer
- U
  undo changes
- M
  mark all files
- M-
  unmark all files
- c, C
  committing changes, input log then C-c C-c
- =, d =
  diff between the selected files and the based version
- d b
  diff between the selected files and the conflict version
- d h
  diff between the selected files and the head revision
- d v
  diff between the selected files and the head revision
  of vendor branch
- O
  updata all selected files
- ?, h
  display help information

using version control with cvs

- C-x v g
  Display the result of the CVS annotate command using colors

- C-x v l
  Display version control state and change history

- C-x v =
  Compare the current buffer contents with the latest checked-in
  version of the file.

- C-u C-x v = FILE  OLDVERS  NEWVERS 
  Compare the specified two versions of FILE.

- C-x v u
  Revert the buffer and the file to the last checked-in version.

- C-x v c
  Remove the last-entered change from the master for the visited
  file.  This undoes your last check-in.

- C-u C-x C-q
  switch another branch.

Using spell checker

- install aspell and add the following to .emacs

  (setq ispell-program-name "aspell")

- M-x ispell
  check for spelling errors

- M-x ispell-buffer
  check the current buffer for errors

using speedbar

- M-x speedbar
  start speedbar to summarize the local

- Q
  Quit speedbar, and kill the frame

- q
  Quit speedbar, and hide the frame

- g
  refresh the speedbar

- n, p
  move to the next or previous item

- +/=
  Expand the current group, displaying sub items

- -
  Contract the current group, hiding sub items.

- M-x speedbar-get-focus RET
  Change frame focus to or from the speedbar frame.

using emacs leim

- C-\
  start input method

- C-X RET f
  change the coding of file. It can save a file into UTF-8 format

other useful tips

- C-q + C-M
  input ^M in emacs

- M-x hl-line-mode
  highlight the current line in Emacs

- C-x Esc Esc
  get the command executed last time

- C-M-a
  go to the head of function definition

- C-M-e
  go to the end of function definition

- C-M-f
  Move forward across one balanced expression 

- C-M-b
  Move backward across one balanced expression

- C-M-d
  Move forward down one level of parentheses

- C-M-u
  Move backward out of one level of parentheses.

- C-c C-u
  go to the begining a  conditional(such as #ifdef)

- C-c C-p
  backward a conditional(#ifdef)

- C-c C-n
  forward a conditional

-M-/
  hippie-expand the sentence have entered.

-M-x dos2unix

  Transformat dos text file to unix

  Add the following to .emacs

  (defun dos2unix ()
  (interactive)
    (goto-char (point-min))
      (while (search-forward "\r" nil t) (replace-match "")))


- M-x unix2dos
  Tranformat unix text file dos
  Add the following to .emacs

  (defun unix2dos ()
  (interactive)
    (goto-char (point-min))
      (while (search-forward "\n" nil t) (replace-match "\r\n")))

- M-x ascii-table
  get the ascii table
  Add the following to .emacs
  
  (defun ascii-table ()
  "Print the ascii table. Based on a defun by Alex Schroeder "
  (interactive)
  (switch-to-buffer "*ASCII*")
  (erase-buffer)
  (insert (format "ASCII characters up to number %d.\n" 254))
  (let ((i 0))
    (while (< i 254)
      (setq i (+ i 1))
      (insert (format "%4d %c\n" i i))))
  (beginning-of-buffer))

- M-x match-paren ( % )
  Add the following to .emacs
  (show-paren-mode t)
  (setq show-paren-style 'parentheses)
  (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)))))

- M-x untabify
  change the tabs into spaces

阅读(669) | 评论(0) | 转发(0) |
0

上一篇:install ADSL on Fedora 6

下一篇:Emacs advanced

给主人留下些什么吧!~~