EMACS AS TEXT EDITOR
The Emacs editor is the very versatile and powerful editor and it understand a LISP which is commonly used language for artificial intelligence programming. It is one of the oldest programming languages still in relatively wide use.Lets take example let say we invent a new programming language and we want to code in this programming language using Emacs but as its a new language so Emacs does not know about it ,so we can write a small LISP program as package and we can load this package to Emacs as we know Emacs Understand LISP so after adding package to Emacs then Emacs can Understand our programming language we would not need to update its binary to be able to code in this programming language
Unlike the vi editor, the Emacs editor does not use an insert mode, and it is by default in editing mode, i.e., whatever you type will directly be written to the buffer, unless you manually enter command mode by using keyboard shortcuts.
1. sudo apt-get install emacs2. emacs3 emacs --version
- 1. to install emacs
- 2. to open emacs
- 3. to check emacs version
1. emacs new.txt2. ctrl+x ctrl+f3. ctrl+x s4 ctrl+x ctrl+s5 ctrl+s ctrl+w6 ctrl+x ctrl+c
- It creates a file called
new.txt
if it doesn’t already exist - opens a file, asks for filename if it can’t find file it creates the file
- save the file with prompt
- save file without prompt
- save file with different name it will asks for name(not work in me)
- for quits emacs and asks for save
Everytime you save a file, Emacs creates another file with the name “filename~” .This (~) file is the previous version of the file. It will be in the same dir. Also, Emacs auto-saves everything you type to a file with the name “#filename#”. If you quit Emacs without saving, you can see this auto-save file. I can show this with help of images
- I created file new (name of file ) with help of above command
2. I will quit from emacs and save the file using above commands and run ls in terminal
3. Now I open same file and edit and then save the changes
4. I quit the emacs and then do ls command
so ,everytime you save a file, Emacs creates another file with the name “filename~” which is previous version.
5. If you want to see difference between the two version the do
diff <filename> <filename2>diff new new~
OTHER SCENARIO
1.In this now i created file called blob and i will exit withou saving from emacs
2. now do ls in terminal
Emacs auto-saves everything you type to a file with the name “#filename#” if you save emacs without saving
MORE COMMNADS
1. Ctrl+k2. ctrl+y3. ctrl+space
|
4. ctrl+M w5. ctrl+w6. ctrl+a7. ctrl+e8. ctrl+/9. esc+>10. esc+<
Saving a region involves hitting ctrl+space to start selecting ,and then hitting M-w or C-w to copy or cut it into the clipboard, and then hitting ctrl+y to paste it. If you don`t like the region you are selecting,hit ctrl+g.
“ctrl+a “ move cursor to the beginning of line
“ctrl+e” move cursor at the end of line
EXECUTION
ctrl+k
ctrl +y
i will just copy “ctrl+y” text in this blog and then paste using ctrl +y in my file
ctrl + space
ctrl+m w
for copying these 4 and to see output paste using ctrl +y
ctrl+a
when i press ctrl+a cursor comes into beginning as shown
ctrl+e
it moves the cursor to the end of line
ctrl+/
it is like undo
esc+> and esc+<
is used for moving at the beginning and end of the file
SO THESE ARE SOME BASIC COMMANDS TO USE EMACS