Editing file in VI Emacs
Introduction
In this lesson, we will introduce the Emacs editor. Emacs like vi is a powerful editor. Some people prefer vi, others prefer Emacs.
Emacs editor
To edit a file with Emacs , run emacs [file]
, the file is the file name that you wish to edit.
When you look at the Emacs documentation, you will see C-<char> , this means to hold down the Ctrl key while pressing that <character>. For example, C-h means to hold down the Ctrl + h.
When you see the M-<char> "Meta" key ( This is Alt key ) while pressing that <character>.
Documentation | Keys | Meaning |
---|---|---|
C-h | Ctrl + h | Help |
C-x C-c | Ctrl + x followed by Ctrl + c | Exit |
C-x C-s | Ctrl + x followed by Ctrl + s | Save the file |
C-h t | Ctrl + h followed by t | Built-in tutorial |
C-h k <key> | Ctrl + h followed by k <key> | The help on key |
Emacs Navigation
In Documentation | Keys | Meaning |
---|---|---|
C-p | Ctrl + p | Previous line |
C-n | Ctrl + n | Next line |
C-b | Ctrl + b | Backward one character |
C-f | Ctrl + f | Forward one character |
M-f | Alt + f | Forward one word |
M-b | Alt + b | Backward one word |
C-a | Ctrl + a | Go to the beginning of the line |
C-e | Ctrl + e | Go to the end of the line |
M-< | Alt + < | Go to the beginning of the file |
M-> | Alt + > | Go to the end of the file |
Emacs - Deleting Text
In Documentation | Keys | Meaning |
---|---|---|
C-d | Ctrl + d | Delete a character |
M-d | Alt + d | Delete a word |
Emacs - Copying, Pasting, and Undo
In Documentation | Keys | Meaning |
---|---|---|
C-k | Ctrl + k | Kill (cut) |
C-y | Ctrl + y | Yank (paste) |
C-x u | Ctrl + x followed by u | Undo |
Emacs - Searching
In Documentation | Keys | Meaning |
---|---|---|
C-s | Ctrl + s | Start a forward search |
C-r | Ctrl + r | Start a reverse search |
Emacs - Repeating Commands
Like vi Emacs provides a way to repeat Commands.
In Documentation | Keys | Meaning |
---|---|---|
C-u N <command> | Ctrl + u followed by N <command> | Repeat <command> N times. |
For example, to kill three lines of text, enter Ctrl + u followed by 3 followed by Ctrl + k.
Latest Post
- Dependency injection
- Directives and Pipes
- Data binding
- HTTP Get vs. Post
- Node.js is everywhere
- MongoDB root user
- Combine JavaScript and CSS
- Inline Small JavaScript and CSS
- Minify JavaScript and CSS
- Defer Parsing of JavaScript
- Prefer Async Script Loading
- Components, Bootstrap and DOM
- What is HEAD in git?
- Show the changes in Git.
- What is AngularJS 2?
- Confidence Interval for a Population Mean
- Accuracy vs. Precision
- Sampling Distribution
- Working with the Normal Distribution
- Standardized score - Z score
- Percentile
- Evaluating the Normal Distribution
- What is Nodejs? Advantages and disadvantage?
- How do I debug Nodejs applications?
- Sync directory search using fs.readdirSync