----BEGIN CLASS---- [13:28] #startclass [13:28] Roll call [13:28] Mayank Singhal [13:28] Ananyo Maiti [13:28] Shiva Saxena [13:28] Priyanka Saggu [13:28] Bhavin Gandhi [13:28] Anu Kumari Gupta [13:28] Jason Braganza [13:28] Shital Mule [13:29] Ratan Kulshreshtha [13:29] kumar vipin yadav [13:29] Akshay Gaikwad [13:29] Robin Schubert [13:30] Sandeep Kumar Choudhary [13:30] Before we begin today's session, couple of points to address [13:30] Piyush Aggarwal [13:30] Manank Patni [13:30] 1. There was a question on why no arrow keys should be used. The reason being that you will have to move your hand from the keyboard to the arrow keys and back, and you will lose time in that [13:31] Hence, the emphasis to learn the keyboard shortcuts and practice them [13:31] 2. In the beginning of the training, we mentioned that you need to use a GNU/Linux distribution installed on your system. https://dgplug.org/summertraining18/ [13:31] Devesh Verma [13:32] <_ryuzaki3> Rituka Patwal [13:32] We want you to learn both software and hardware, and using FLOSS with the source code helps you with that. Using Mac is useless, because they control the hardware. So, we strongly recommend that you _only_ use GNU/Linux for learning, and the know-how will help you in your career [13:33] Today, we will start with "Clipboard commands". Open GNU Emacs from the GUI menu, or from the terminal using: [13:33] => $ emacs -Q [13:33] You see the *scratch* buffer and some text in it already [13:34] To delete a character, you can use: [13:34] => C-d [13:34] If you want to delete a word, you can use: [13:34] => M-d [13:34] Again, 'd' for delete, Control for single character, and Meta for a word (list of characters) [13:35] Farhaan Bukhsh [13:35] Please try these shortcuts [13:36] done [13:37] To delete from cursor to end of line, you can use: [13:37] => C-k [13:37] To delete the next sentence, you can use: [13:37] => M-k [13:37] Again, 'k' for kill, Control for till end of line, and Meta for end of next sentence [13:38] You might want to type or paste paragraphs from the web for playing around in the *scatch* buffer [13:39] If you want to undo the cut, you can use: [13:39] => C-x u [13:40] Again, 'u' for undo. Also to undo the previous operation [13:40] Also, if you want to undo the previous 'n' commands, you can use: [13:40] => C-u n C-x u [13:41] If you want to paste whatever you have cut, you can use: [13:41] => C-y [13:42] All your cut operatins are stord in a ring (circular) buffer. So, you can go back and paste them again. So, after C-y, you can type M-y to paste the earlier deletion [13:42] If you repeatedly type M-y, it will continue pasting the previous deleted entries from the kill ring buffer [13:45] You can select a block of text [13:45] Place the cursor somewhere in the middle of a sentence and type: [13:45] => C-space [13:45] In the minibuffer, you will see "Mark set" [13:46] This marks the beginning of the text [13:46] Now, use the control chararcters to move forward three words [13:47] => C-u 3 M-f [13:47] Now, this marks the end of three words. Now, you can copy this marked (highlighted) region using: [13:47] => M-w [13:48] You can move the cursor to anywhere in the buffer and to paste it, you can use: [13:48] => C-y [13:48] After marking a region of text, if you want to delete this marked region, you can use: [13:48] => C-w [13:49] If you want to mark (or select) a paragraph, you can use: [13:49] => M-h [13:49] If you want to mark (or select) the entire buffer, you should use: [13:50] => C-x h [13:51] The above are some basic clipboard commands [13:51] Let's now move on to formatting text [13:52] If you have copy pasted text from the browser or other documents into the Emacs buffer or file, you may see that the line wraps around [13:53] and the text may split between the end of the line, and the next line. If you want to use 80 character width in a paragraph, you can use: [13:53] => M-q [13:53] This is for "reformat paragraph" [13:55] If you want to join the current line (say beginning of a paragraph) to the previous line (last line of the previous paragraph), you can use: [13:55] => M-^ [13:55] Again, the "^" indicates to the previous [13:57] If, you mis-spelt "teh" and you want to transpose characters, place the cursor on 'h' and press: [13:57] => C-t [13:57] This is to transpose characters [13:58] If you want to transpose words, you have to use: [13:58] => M-t [13:58] Control for character and Meta for word, and 't' for transpose. Very intuitive indeed! [14:00] You can transpose lines using: [14:00] => C-x C-t [14:01] If you want to capitalise a word, you can go to the beginning of the word, and type: [14:01] => M-c [14:02] 'c' here for captialize [14:02] If you want to uppercase the word, you can go to the beginning of the word, and type: [14:02] => M-u [14:02] 'u' for upper case [14:03] If you want to lowercase the word, go to the beginning of the word, and type: [14:03] => M-l [14:03] 'l' for lower case [14:03] If you use any of these commands in the middle of the word, the operation is undertaken from the cursor till the end of the word [14:05] If you want to capitalize the previous word, you can use: [14:05] => M - M-c [14:06] You want to uppercase the previous word, you can use: [14:06] => M - M-u [14:06] And, if you want to lowercase the previous word, you can use: [14:06] => M - M-l [14:07] You have to keep the cursor on the beginning of the word to take effect on the previous word. [14:07] This covers some basic formatting text commands [14:08] ! [14:08] next [14:09] I'm a little confused on how to type M - M-l [14:09] ! [14:09] storymode7, Press Alt and -. Remove the finger from the - key, and while you keep pressing Alt, press 'l' [14:09] next [14:10] The previous commands capitalizes the next word [14:10] in my case [14:10] mbuf: thanks. [14:11] priyankasaggu119: try the key combination suggested by mbuf in the last message [14:11] the - is literal [14:11] priyankasaggu119, what did you type? [14:12] I am pressing M then next M and then typing c [14:12] priyankasaggu119, you have to press M followed by "-" (dash) [14:12] ohk storymode7, i got the point. [14:12] thanks mbuf, i got it. [14:12] priyankasaggu119, in this case, you were typing only M-c, and hence it capitalizes the next word [14:13] yes mbuf [14:13] We have now done some basic clipboard and formatting text commands. [14:13] Let us now move on to buffer commands [14:14] As I mentioned yesterday, everything is a buffer in Emacs. You could be having a chat on an IRC channel, or composing e-mail, or writing code, or reading PDF - everything is a buffer. [14:14] If you want to switch to another buffer you can use: [14:14] => C-x b [14:14] It will prompt in the minibuffer with: [14:15] Switch to buffer (default *Messages*): [14:15] You can hit "TAB" here to see possible completions, and type the buffer you want to switch to [14:15] For example: [14:15] => *Mess [14:15] Hit enter, and you will now are in the *Messages* buffer [14:16] You can switch back to the *scratch* buffer again using: [14:16] => C-x b [14:16] At the prompt, you can type "*scr" and hit TAB to auto-complete, and hit enter [14:19] You can display the buffer list using: [14:19] => C-x C-b [14:20] It will open another window showing the *Buffer List* [14:20] You can now see two windows split horizontally [14:20] The entire Emacs frame consists of two windows. This is Emacs terminology [14:21] If your cursor is in the *scratch* buffer, you can close all other windows using: [14:21] => C-x 1 [14:21] Now, you have a single frame with a single window, which contains the *scratch* buffer [14:22] You can rename a buffer, if you want using: [14:22] => M-x rename-buffer [14:23] You can save a buffer to a file using: [14:23] => C-x s [14:24] Let us know look at *Buffer list* commands [14:24] From the scratch buffer, type C-x C-b to open a new window with the list of buffers [14:25] You can move the cursor to the next window using: [14:25] => C-x o [14:25] 'o' for other window in this context [14:25] If you press C-x o from the *Buffer list* window, the cursor will jump back to the *scratch* buffer window [14:26] See how fast you can move cursor across windows without the mouse! [14:26] You did not move your fingers away from the keyboard! [14:27] Now, when you are in the *Buffer List* buffer window, it is like any other buffer, and you can use C-p (previous) and C-n (next) to move the cursor up and down [14:28] Let us say we want to delete the *scratch* buffer. In the *Buffer List* buffer window, go to the line where the *scratch* buffer entry is and press: [14:28] => d [14:28] You will see that the entry at the beginning is marked with 'D'. This means that this buffer has been marked for deletion. [14:29] Now, in this *Buffer List* window, you are issuing commands (no text) to work with the buffers [14:29] You can unmark a buffer using: [14:29] => u [14:29] Again, 'd' for delete and 'u' for unmark [14:30] Mark the *scratch* buffer for deletion using 'd' and from anywhere in the buffer, press: [14:30] => x [14:31] This will execute the operations that have been marked on the buffers. In this case, we are deleting the *scratch* buffer [14:31] 'x' here means execute. [14:33] Exit Emacs (C-x C-c) and re-open Emacs, and you should get the *scratch* buffer again. [14:34] Now type some text in the scratch buffer, and open the buffer list again with C-x C-b [14:35] Use C-o to go to the *Buffer List* window, and on the *scratch* buffer entry press: [14:35] => s [14:35] This is to mark the buffer for save. Now, if you press 'x' to execute, GNU Emacs will prompt for you to save the buffer to a file in the minibuffer. You can enter, say /tmp/scratch.txt. [14:36] You can change (toggle) a buffer status to read-only in the *Buffer List* buffer using: [14:36] => % [14:36] ! [14:36] In the mode-line for scratch.txt you will see %%, which means the buffer is now read only [14:36] next [14:37] Sorry mbuf I need to leave. But I had a question [14:37] I know I’m getting a little ahead of myself, but this is key, if I want to get into emacs. When you extend emacs functionality via plugins or their ilk, do work smoothly like they were always part of emacs? They feel natural? [14:37] jasonbraganza, sure [14:37] jasonbraganza, yes [14:38] jasonbraganza, these are just basics; we will talk about customizations later (in my list of sessions) [14:38] Thank you :) [14:39] Now, if you use C-x o to go to the scratch.txt file window, and type anything, you will see a message in the minibuffer that "Buffer is read-only". [14:40] You can toggle it back using '%', and you should be able to enter text in scratch.txt again. [14:40] There are other buffer list commands that you can try. In the *Buffer List* window, go to the entry and type: [14:40] => 1 [14:40] And it will display the buffer in the full screen [14:41] You can go to the *Messages* entry list in the *Buffer List* and type: [14:41] => o [14:41] Which will replace the other buffer with the *Messages* buffer [14:42] If you want to replace the *Buffer List* window with a particular buffer or file, say scratch.txt, move the cursor to the entry and press: [14:42] => f [14:42] Which is replace buffer list with this buffer [14:43] Finally, you can quit the *Buffer List* window using: [14:43] => q [14:43] Remember that closing a window does not mean closing the buffer or file. They still exist. [14:43] You are only changing the view of your editor. The buffers and files still exist. [14:44] These are some basic Buffer and Buffer list commands. [14:44] Let us now move on to Windows commands [14:44] http://www.shakthimaan.com/images/emacs/c-x-plus.png [14:44] The above is a single GNU Emacs frame with three windows, each having the same *scratch* buffer. [14:45] In different windows, you can have the same buffer or file, but, the cursor can be at a different location in each of the three windows. [14:45] If you update the text any one window, it is automatically updated in the other windows as well. [14:45] http://www.shakthimaan.com/images/emacs/custom-windows.png [14:46] The above picture shows a GNU Emacs frame with three windows. The left window has the *scratch* buffer. [14:46] The right window is split between the Emacs shell and the *Messages* buffer. [14:46] You can split a window horizontally using: [14:46] => C-x 2 [14:47] In this context, I meant the divider is horizontal [14:48] But, the windows are positioned vertically. Some documents refer this as vertical splitting. [14:48] You can split two windows side-by-side with a vertical divider using: [14:48] => C-x 3 [14:49] Some documents refer to this as horizontal splitting, because, the windows are side-by-side [14:49] You already know to move to the other window(s) using: [14:49] => C-x o [14:49] ! [14:49] If you want to delete a current window (_not_ the buffer or file) you can use: [14:50] => C-x 0 [14:50] The above is zero. [14:50] next [14:50] how to close one window ? [14:50] ananyo, I just typed that, C-x 0 [14:51] oh ok [14:51] Remember, you are only closing the window. The buffer or file is still in memory or disk respectively. [14:51] If you only want the current window, and want to close all other windows, you can use: [14:51] => C-x 1 [14:53] If you have two windows (say split with a vertical divider), and the cursor is on the left window, and you want to open a file in the other window, you can use: [14:53] => C-x 4 f [14:54] If you want to select a buffer in the other window, you can use: [14:54] => C-x 4 b [14:55] You can enlarge the window (push it up) using: [14:55] => C-x ^ [14:55] You can shrink it down (lower it) using: [14:55] => M-x shrink-window [14:57] You can enlarge a window horizontally using: [14:57] => C-x } [14:57] You can shrink the window horizontally using: [14:57] => C-x { [14:58] Note again that '}' is towards the right, and '{' is towards the left. [14:58] Again, you can use the prefix command: [14:58] => C-u 5 C-x } [14:59] Depending on your screen size, and the work you are doing, you can have code in one window, IRC on another window, shell in another window etc. [15:00] If you have different proportion for each window, and you want to balance the windows equally use: [15:00] => C-x + [15:00] From one window, you can scroll the text in the other window using: [15:01] => C-M-v [15:02] If you want to scroll the text down (to see the text on the top), you can use: [15:02] => C-M-shift-v [15:02] Since, I used Dvorak layout, for this I use the left hand for control+alt+shift and right hand for 'v'. [15:03] But, you can also simple C-o to the window and use C-v and M-v to scroll up and down [15:03] Let us move on the final section for today - Frame commands [15:04] If you have a large screen (monitor), you can open multiple GNU Emacs frames. You can create one using: [15:04] => C-x 5 2 [15:04] You can move (or jump) the cursor between frames using: [15:04] => C-x 5 o [15:06] If you want to find a file in the new frame, you can use: [15:06] => C-x 5 f [15:07] If you want to switch to a buffer in the new frame, you can use: [15:07] => C-x 5 b [15:08] If you want to open a file in the new frame in read-only mode, you can use: [15:08] => C-x 5 r [15:08] And if you want to delete the current frame, use: [15:09] => C-x 5 0 [15:09] These are some basic Frames commands. [15:09] We have discussed a lot of commands today. [15:09] The homework for the weekend is to try all these commands, including the ones you have learnt yesterday. [15:10] I want all of you to use GNU Emacs as your primary editor for whatever work you are doing. [15:10] Unless you use it on a daily basis, you are not going to master it. [15:11] what's the speciality in emacs [15:11] To summarise, we have covered Clipboard, Formatting text, Buffer, Windows and Frame commands. [15:11] rogers_, use "!" if you want to ask a question [15:12] ok [15:13] Roll call [15:13] Mayank Singhal [15:13] Priyanka Saggu [15:13] hey,!how cam i mention someone here in a message [15:13] Ashish Kumar Mishra [15:13] Anu Kumari Gupta [15:13] Shiva Saxena [15:13] Bhavin Gandhi [15:13] Neeraj Kumar Arya [15:13] Sandeep Kumar Choudhary [15:13] Akshay Gaikwad [15:14] Bhavesh Gupta [15:14] Ananyo Maiti [15:14] Prashant Sharma ----END CLASS----