Difference between revisions of "Emacs keys"

From Jens' Hjørne
Jump to navigation Jump to search
m
m
 
(4 intermediate revisions by the same user not shown)
Line 23: Line 23:
 
|style="background-color:#ffffcc;"|Document||&nbsp;||M->||&nbsp;||Move to the end of the document||&nbsp;||M-<||&nbsp;||Move to the start of the document
 
|style="background-color:#ffffcc;"|Document||&nbsp;||M->||&nbsp;||Move to the end of the document||&nbsp;||M-<||&nbsp;||Move to the start of the document
 
|}
 
|}
 +
 
==Editing==
 
==Editing==
 
{|
 
{|
Line 47: Line 48:
 
|C-y||&nbsp;||Yank back killed text at current cursor position. M-y will then cycle through earlier killed texts.
 
|C-y||&nbsp;||Yank back killed text at current cursor position. M-y will then cycle through earlier killed texts.
 
|}
 
|}
 +
 
==File handling, buffers and exiting==
 
==File handling, buffers and exiting==
 
{|
 
{|
Line 68: Line 70:
 
|-
 
|-
 
|C-x i||&nbsp;||insert file at cursor position
 
|C-x i||&nbsp;||insert file at cursor position
 +
|}
 +
 +
==Ctags in Emacs==
 +
Generate the TAGS file by running this script in your source directory:
 +
#!/bin/bash
 +
find /usr/include -name \*.h | xargs etags -a
 +
find /usr/local/include -name \*.h | xargs etags -a
 +
etags -a *.c *.cc *.scc *.cpp ../incl/*.h ../incl/tm3/*.h ../shared/*.h *.cinclude
 +
 +
The -a parameter appends to an existing TAGS file.
 +
 +
{|
 +
!align="left"|Key!!&nbsp;!!align="left"|Function
 +
|-
 +
|M-. <Enter>||&nbsp;||Go to tag under the cursor
 +
|-
 +
|M-. <tag> <Enter>||&nbsp;||Search for a specific tag
 +
|-
 +
|C-u M-.||&nbsp;||Go to the next definition for the last tag found
 +
|-
 +
|M-*||&nbsp;||Go back to where you invoked "M-."
 
|}
 
|}
  
Line 82: Line 105:
 
|C-h k <key>||&nbsp;||Get help on key
 
|C-h k <key>||&nbsp;||Get help on key
 
|}
 
|}
−
 
−
 
−
L453
 
  
 
[[Category:Værktøjer, Programmering]][[Category:Keyboard shortcuts]]
 
[[Category:Værktøjer, Programmering]][[Category:Keyboard shortcuts]]

Latest revision as of 09:55, 24 January 2018

Links to check

Movement

    Forward   Backward
Unit   Key   Function   Key   Function
Character   C-f   Move one character forward   C-b   Move one character backward
Word   M-f   Move one word forward   M-b   Move one word backward
Line   C-n   Move to next line   C-p   Move to previous line
Line   C-e   Move to end of line   C-a   Move to beginning of line
Sentence   M-e   Move forward to end of sentence   M-a   Move back to beginning of sentence
Document   M->   Move to the end of the document   M-<   Move to the start of the document

Editing

Key   Function
<DelBack>   BackSpace - Delete character just before cursor
C-d   Delete next character after the cursor
M-<DelBack>   Kill word before cursor
M-d   Kill word after the cursor
C-k   Kill to end of line (not including the newline). When given a count parameter C-k will kill to end of line including the newline for each count.
M-k   Kill to end of sentence
C-@   Set mark
C-Spc   Set mark
C-w   Kill from set mark to just before cursor position
C-y   Yank back killed text at current cursor position. M-y will then cycle through earlier killed texts.

File handling, buffers and exiting

Key   Function
C-x C-f   find (open or create) file (prompted for filename)
C-x C-s   save file
C-x C-w   save file as ...
C-x s   save all files
C-x C-c   save files, exit emacs
C-x k   kill current buffer
C-x b   move to or create another buffer (prompt for buffer name)
C-x C-b   show buffer list
C-x i   insert file at cursor position

Ctags in Emacs

Generate the TAGS file by running this script in your source directory:

#!/bin/bash
find /usr/include -name \*.h | xargs etags -a
find /usr/local/include -name \*.h | xargs etags -a
etags -a *.c *.cc *.scc *.cpp ../incl/*.h ../incl/tm3/*.h ../shared/*.h *.cinclude

The -a parameter appends to an existing TAGS file.

Key   Function
M-. <Enter>   Go to tag under the cursor
M-. <tag> <Enter>   Search for a specific tag
C-u M-.   Go to the next definition for the last tag found
M-*   Go back to where you invoked "M-."

Various

Key   Function
C-u   Repeat count for command.
Alternate: Hold M while typing count.
C-v and M-V scrolls by that many lines when given a repeat count
C-g   Abort command or repeat count
C-x 1   Back to one window
C-h k <key>   Get help on key