From 7236d9a716a0e24affa4981b5a91cd61e35f90a2 Mon Sep 17 00:00:00 2001 From: Dmitry Barskov Date: Sun, 18 Sep 2022 00:29:00 +0200 Subject: [PATCH 1/8] Add Makefile --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cf25bed --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +present: + reveal-md . -w --theme solarized --highlight-theme monokai + +serve: + bundle exec jekyll serve From 55923c3b6ce47ef891d0b0a6e9798c817e6187ae Mon Sep 17 00:00:00 2001 From: Dmitry Barskov Date: Sun, 18 Sep 2022 00:30:30 +0200 Subject: [PATCH 2/8] Emacs tutorial --- _posts/2022-09-14-emacs.md | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 _posts/2022-09-14-emacs.md diff --git a/_posts/2022-09-14-emacs.md b/_posts/2022-09-14-emacs.md new file mode 100644 index 0000000..2f95d6b --- /dev/null +++ b/_posts/2022-09-14-emacs.md @@ -0,0 +1,62 @@ +--- +layout: post +title: "[Work in Progress] Emacs Basics" +date: 2022-09-14 09:13:00 +0100 +categories: tools +--- + +## Basics + +Emacs is a text editor with command line interface. It allows to edit a text +using only keyboard. You can write text on it as usual and perform "shortcuts" +to perform some actions with the editor and the text. + +These "shurtcuts" are called commands. + +``` + C-x C-c Close the editor. +``` +To perform this command you have to press "x" key when CTRL key is hold +and then press "c" key when CTRL key is hold. +In commands first "C-" means CTRL key. +"M-" means Meta key which is usually labeled "alt" or "option". + +> NOTE: not all terminals support Meta key. +But it can be emulated by pressing ESC key and then a target key sequentially. +For example for command `M-f` you can press "f" while holding "alt" or you can +type ESC and then press "f". + +## Movements + +Here is a summary of simple cursor-moving operations, +including the word and sentence moving commands: + +``` + C-f Move forward a character + C-b Move backward a character + + M-f Move forward a word + M-b Move backward a word + + C-n Move to next line + C-p Move to previous line + + C-a Move to beginning of line + C-e Move to end of line + + M-a Move back to beginning of sentence + M-e Move forward to end of sentence + + M-< Move to beginning of whole text + M-> Move to end of whole text + + C-l Position line with cursor at the center of screen. + If it is at the center, position at the top. + If at the top, position at the bottom. + If at bottom then position at the center and so on. + + C-u Perform command times. + E. g. C-u 5 C-n will move to next line 5 times. + + M- Same as above. Type when holding Meta. +``` From 41e4cf4cfd364745e7f5c76db0dd4b6c48cf6a9f Mon Sep 17 00:00:00 2001 From: Dmitry Barskov Date: Sun, 18 Sep 2022 00:30:57 +0200 Subject: [PATCH 3/8] Remove wip badge --- _posts/2022-09-14-emacs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_posts/2022-09-14-emacs.md b/_posts/2022-09-14-emacs.md index 2f95d6b..0f61b8d 100644 --- a/_posts/2022-09-14-emacs.md +++ b/_posts/2022-09-14-emacs.md @@ -1,6 +1,6 @@ --- layout: post -title: "[Work in Progress] Emacs Basics" +title: "Emacs Basics" date: 2022-09-14 09:13:00 +0100 categories: tools --- From 9f908cf623eab2348b2ef0fe795b6bb3ec6b3098 Mon Sep 17 00:00:00 2001 From: Dmitry Barskov Date: Mon, 19 Sep 2022 00:15:49 +0200 Subject: [PATCH 4/8] 31% --- _posts/2022-09-14-emacs.md | 80 ++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/_posts/2022-09-14-emacs.md b/_posts/2022-09-14-emacs.md index 0f61b8d..f3ba8aa 100644 --- a/_posts/2022-09-14-emacs.md +++ b/_posts/2022-09-14-emacs.md @@ -14,7 +14,7 @@ to perform some actions with the editor and the text. These "shurtcuts" are called commands. ``` - C-x C-c Close the editor. +C-x C-c Close the editor. ``` To perform this command you have to press "x" key when CTRL key is hold and then press "c" key when CTRL key is hold. @@ -32,31 +32,71 @@ Here is a summary of simple cursor-moving operations, including the word and sentence moving commands: ``` - C-f Move forward a character - C-b Move backward a character +C-f Move forward a character +C-b Move backward a character - M-f Move forward a word - M-b Move backward a word +M-f Move forward a word +M-b Move backward a word - C-n Move to next line - C-p Move to previous line +C-n Move to next line +C-p Move to previous line - C-a Move to beginning of line - C-e Move to end of line +C-a Move to beginning of line +C-e Move to end of line - M-a Move back to beginning of sentence - M-e Move forward to end of sentence +M-a Move back to beginning of sentence +M-e Move forward to end of sentence - M-< Move to beginning of whole text - M-> Move to end of whole text +M-< Move to beginning of whole text +M-> Move to end of whole text - C-l Position line with cursor at the center of screen. - If it is at the center, position at the top. - If at the top, position at the bottom. - If at bottom then position at the center and so on. +C-l Position line with cursor at the center of screen. + If it is at the center, position at the top. + If at the top, position at the bottom. + If at bottom then position at the center and so on. +``` + +Most of commands be prefixed with `C-u ` for a repeat count. +But `C-v` and `M-v` take it as amount of lines to scroll. E.g. `C-u 10 C-v` +will scroll down 4 lines trying to leave cursor in its place. + +``` +C-u Perform command times. + E. g. C-u 5 C-n will move to next line 5 times. + +M- Same as above. Type when holding Meta. +``` + +You can abort current command by `C-g`. If you change your mind after typing +a part of a command you can abort it by `C-g`. Or you can use it to abort long +running command. + +So if you type `C-u 100 C-g C-f` it would move cursor forward by 1 symbol +because you cancelled it with `C-g`. + +If you type an unsafe command (`C-x C-l` for example) you see a window +to confirm it. This happened because emacs has "disabled" commands for a noob's +safety. Press `n` to cancel it and `` (space) to confirm. - C-u Perform command times. - E. g. C-u 5 C-n will move to next line 5 times. +## Windows - M- Same as above. Type when holding Meta. +`C-x 1` kill all windows other than 1. + +## Editing + +Just type text :) + +You can give repat count to a symbol to insert it many times: + +``` +M-3 i produces "iii" +``` + +Delete text as usual with DEL or Backspace keys. Or... +``` +C-d delete the character under (after for |) the cursor +M- kill the word before the cursor +M-d kill the word after the cursor +C-k kill to end of line +M-k kill to the end of sentence ``` From 3cc1eb5381b2dc90712d02db43d4354efde40257 Mon Sep 17 00:00:00 2001 From: Dmitry Barskov Date: Thu, 22 Sep 2022 23:13:26 +0200 Subject: [PATCH 5/8] Add info on sentences --- _posts/2022-09-14-emacs.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_posts/2022-09-14-emacs.md b/_posts/2022-09-14-emacs.md index f3ba8aa..df53298 100644 --- a/_posts/2022-09-14-emacs.md +++ b/_posts/2022-09-14-emacs.md @@ -89,7 +89,8 @@ Just type text :) You can give repat count to a symbol to insert it many times: ``` -M-3 i produces "iii" +M-3 i produces "iii" +M-3 removes 3 symbols ``` Delete text as usual with DEL or Backspace keys. Or... @@ -100,3 +101,6 @@ M-d kill the word after the cursor C-k kill to end of line M-k kill to the end of sentence ``` + +> The sentence commands assume that you follow the American typist’s +convention of putting two spaces at the end of a sentence. From a18eaa57c5f638a31f1f0fe4c88fcffc2e03575c Mon Sep 17 00:00:00 2001 From: Dmitry Barskov Date: Mon, 26 Sep 2022 17:12:27 +0200 Subject: [PATCH 6/8] Update emacs --- _posts/2022-09-14-emacs.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/_posts/2022-09-14-emacs.md b/_posts/2022-09-14-emacs.md index df53298..37712e0 100644 --- a/_posts/2022-09-14-emacs.md +++ b/_posts/2022-09-14-emacs.md @@ -87,20 +87,32 @@ safety. Press `n` to cancel it and `` (space) to confirm. Just type text :) You can give repat count to a symbol to insert it many times: +Next ` = backspace` ``` -M-3 i produces "iii" -M-3 removes 3 symbols +M-3 i produces "iii" +M-3 removes 3 symbols ``` Delete text as usual with DEL or Backspace keys. Or... ``` -C-d delete the character under (after for |) the cursor + delete the character before the cursor +C-d delete the character under (after) the cursor + M- kill the word before the cursor M-d kill the word after the cursor + C-k kill to end of line M-k kill to the end of sentence ``` > The sentence commands assume that you follow the American typist’s convention of putting two spaces at the end of a sentence. + +```text +C- Set mark/Start text selection/Visual mode in Vim +C-w Kill selected text +``` + +In the previous paragraph there were "kill" and "delete" terms. "Kill" is the +same as "delete" but it copies the text (yanks). E.g. it is "cut". From cfabbb0a3d378906fe8d08c70dce34ef3a56dc7b Mon Sep 17 00:00:00 2001 From: Dmitry Barskov Date: Fri, 7 Oct 2022 14:01:25 +0200 Subject: [PATCH 7/8] WIP --- _posts/2022-09-14-emacs.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/_posts/2022-09-14-emacs.md b/_posts/2022-09-14-emacs.md index 37712e0..5579742 100644 --- a/_posts/2022-09-14-emacs.md +++ b/_posts/2022-09-14-emacs.md @@ -111,8 +111,13 @@ convention of putting two spaces at the end of a sentence. ```text C- Set mark/Start text selection/Visual mode in Vim -C-w Kill selected text +C-w Kill (cut) selected text +C-y Yank (paste) killed text +M-y Yank previous kill and replace paste buffer with text killed earlier ``` In the previous paragraph there were "kill" and "delete" terms. "Kill" is the -same as "delete" but it copies the text (yanks). E.g. it is "cut". +same as "delete" but it copies the text. + + + From c8bf64ba88186ae6f3f82e0b69e6605040512082 Mon Sep 17 00:00:00 2001 From: Dmitry Barskov Date: Sun, 16 Oct 2022 17:44:57 +0200 Subject: [PATCH 8/8] Add text and buffers paragraphs --- _posts/2022-09-14-emacs.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/_posts/2022-09-14-emacs.md b/_posts/2022-09-14-emacs.md index 5579742..1d120c2 100644 --- a/_posts/2022-09-14-emacs.md +++ b/_posts/2022-09-14-emacs.md @@ -119,5 +119,30 @@ M-y Yank previous kill and replace paste buffer with text killed earlier In the previous paragraph there were "kill" and "delete" terms. "Kill" is the same as "delete" but it copies the text. +To undo latest changes type `C-/` or `C-_` or `C-x u`. + +## Files + +Current opened file name can be found at the bottom of the screen. +To open a file type `C-x C-f` and type a file name. To write changes type +`C-x C-s`. + +First time you type `C-x C-s` focus will jump to the bottom screen +mini-buffer and prompt you a file name to write. + +When editing and saving file emacs copies unedited version with the same +name suffixed by "~" not to lose it. + +## Buffers + +You can open one file, then another by typing `C-x C-f ` and so on. +All these files remain open in Emacs and stored in "buffers". + +To switch between buffers type `C-x b `. + +Emacs does not save files when you switch current buffer, but you don't have +to switch to the right buffer to save it - use `C-x s` (save unsaved buffers). + +## Commands