----BEGIN CLASS----
[13:58] <mbuf> #startclass
[13:58] <mbuf> Roll call
[13:58] <gutsytechster> Prashant Sharma
[13:58] <shiva> Shiva Saxena
[13:58] <brute4s99> Piyush Aggarwal
[13:58] <bhavin192> Bhavin Gandhi
[13:58] <priyankasaggu119> Priyanka saggu
[13:58] <schubisu> Robin Schubert
[13:59] <devesh_verma> Devesh Verma
[13:59] <mbuf> Before we begin today's class, I want to mention few important points
[14:00] <mbuf> The commands that we are learning in these sessions are the basic ones.
[14:00] <mbuf> If you do more reference, you will find more commands for the different categories that we are addressing here. So, do not think that these are the only ones available.
[14:01] <mbuf> Secondly, from the discussions on IRC, we see that some of you do not take notes when reading.
[14:01] <mbuf> You cannot spend the same time again reading a book or material, so, keeping notes is a very good habit.
[14:02] <mbuf> I see some of you have started to prepare a "cheat sheet". Please note that we are not cheating here. GNU Emacs is under a Free Software license that allows you to go through its source code.
[14:02] <mbuf> "Quick reference" sheet or card is probably a better name.
[14:03] <mbuf> We have the APAC Emacs meeting on the third Monday of every month. Some of you attended the meeting, and I am happy about it.
[14:03] <mbuf> Try to attend the same regularly, and feel free to share whatever new you have learnt with Emacs in the meetup.
[14:04] <mbuf> It starts at 1900 IST and audio meeting happens using Jitsi
[14:04] <mbuf> For today's class, let us begin with "Search" commands
[14:04] <mbuf> Please download this .txt file https://www.gutenberg.org/files/11/11-0.txt to /tmp.
[14:05] <BhaveshSGupta> Bhavesh Gupta
[14:05] <pooja_s> pooja sulakhe
[14:05] <mbuf> Start Emacs using:
[14:05] <mbuf> => $ emacs -Q
[14:06] <mbuf> and open the file /tmp/11-0.txt
[14:07] <mbuf> You can start an incremental search forward using:
[14:07] <mbuf> => C-s
[14:07] <mbuf> In the minibuffer you will see the text "I-search:"
[14:08] <mbuf> Simply start typing 'alice' (without the quotes)
[14:08] <mbuf> You will see that the firs occurrenc of "Alice" in the first line gets highlighted, and also the other "alice" in the buffer
[14:09] <mbuf> If you press the following again, it will repeat the previous search and move the cursor to the next occurrence of 'alice':
[14:09] <mbuf> => C-s
[14:09] <mbuf> You can keep pressing C-s, and the cursor will keep moving forward to the next occurrence of 'alice'
[14:09] <mbuf> If you want to search backward for this current word 'alice', you can press:
[14:10] <mbuf> => C-r
[14:10] <sandeepK> Sandeep Kumar Choudhary
[14:10] <mbuf> This is for starting incremental search backward
[14:10] <__rex__> jj b
[14:10] <mbuf> Anytime, you want to exit during the incremental search, simply press the enter key
[14:10] <mbuf> => <enter>
[14:11] <mbuf> Or if you want to cancel the incremental search, you can use:
[14:11] <mbuf> => C-g
[14:12] <mbuf> Now, move the cursor to the beginning of the file
[14:13] <mbuf> The cursor should be in the letter 'P' in the first line
[14:13] <mbuf> To incrementally search the word on the cursor, you can use:
[14:13] <mbuf> => C-s C-w
[14:13] <mbuf> 's' for search and 'w' for word
[14:14] <mbuf> And then you can keep pressing C-s C-s to repeat this search, and the cursor will move to all occurrences of the word 'project'
[14:14] <VirtualRcoder> Roll call : Shubham Sharma
[14:15] <mbuf> If you want to start an non-incremental search forward, you can use:
[14:15] <mbuf> => C-s <enter> searchstring <enter>
[14:16] <mbuf> As soon as you hit 'C-s <enter>", in the minibuffer, the text will show with prompt "Search:"
[14:16] <mbuf> You can type in the searchstring and press <enter>
[14:16] <mbuf> The cursor will move to the end of the first matched searchstring
[14:17] <mbuf> For example, if your cursor is in the first character on the first line of the file, you can try:
[14:17] <brute4s99> !
[14:17] <mbuf> => C-s <enter> carroll <enter>
[14:18] <mbuf> and the cursor will move to the end of the first line where the word 'Carroll' ends.
[14:18] <mbuf> next
[14:18] <brute4s99> The mini buffer says: "Mark saved where search started" . How to get back to that mark, mbuf?
[14:19] <mbuf> brute4s99, that is just for information
[14:19] <brute4s99> okay, mbuf <eom>
[14:21] <mbuf> brute4s99, when your cursor was in 'P' in the first character in the first line, that is the position of the mark
[14:22] <mbuf> brute4s99, after your search, the cursor moved to the end of the line. If you use C-x C-x, Emacs will switch between the cursor and the mark
[14:22] <mbuf> brute4s99, you can keep pressing C-x C-x repeatedly, and it will switch the cursor
[14:22] <mbuf> brute4s99, to the mark
[14:23] <brute4s99> wow, mbuf this is great! it's like having two cursors !
[14:23] <mbuf> brute4s99, when you alse use clipboard commands, and you mark (C-space for mark) and select a region, Emacs will save the position, and you can use C-x C-x to switch the cursor between the mark and cursor position
[14:24] <mbuf> You can start a nonincremental search backward using:
[14:24] <mbuf> => C-r <enter> searchstring <enter>
[14:26] <mbuf> So far we have seen case insensitive searches. If you want case sensitive search, you can use regular expressions.
[14:27] <mbuf> To do a search regex forward, use:
[14:27] <mbuf> => C-M-s <regex> <enter>
[14:27] <mbuf> For example, you can try:
[14:28] <mbuf> => C-M-s ^CHAPTER
[14:28] <mbuf> And then you can repeatedly hit C-s C-s to look at all the chapter titles
[14:28] <mbuf> To continue the reverse search for the same regex, you can use C-r C-r
[14:28] <mbuf> The '^' symbol in regex matches the beginning of line
[14:30] <mbuf> When you press C-M-s, the minibuffer will change to "Regexp I-search:" and you can simply type the regex in it
[14:31] <mbuf> Another regex example to try will be 'donate\.$' (without the quotes)
[14:31] <mbuf> The '$' represents the end of a line, and we are matching for a sentence that ends with the word 'donate'.
[14:32] <mbuf> If you are familiar with regex, then learning the supported regex characters in GNU Emacs should be trivial. Your homework is to become familiar with the other regex characters.
[14:32] <mbuf> You can do a search regex backward using:
[14:32] <mbuf> => C-M-r <regex> <enter>
[14:33] <mbuf> If you want to do a search regex in incremental fashion, use:
[14:33] <mbuf> => C-M-s
[14:33] <mbuf> Similarly, for search regex incrementally backward, use:
[14:33] <mbuf> => C-M-r
[14:35] <brute4s99> !
[14:35] <mbuf> next
[14:35] <brute4s99> why would someone use C-M-r if she can use C-M-s and then C-r ?
[14:36] <mbuf> brute4s99, if you want to do a search backward, why do you want to search forward and go back?
[14:36] <mbuf> brute4s99, if you want to use the reverse gear, why do you want to use the first gear?
[14:37] <brute4s99> but after C-M-r, I would have to use C-r to get to backward next occurence, right?
[14:37] <mbuf> brute4s99, for incremental search, as you type, the cursor will automatically move to the first occurrence in the backward direction
[14:38] <mbuf> brute4s99, for C-M-r
[14:39] <brute4s99> mbuf, for next occurence in backward fashion, I meant
[14:39] <brute4s99> (for 2nd occurence)
[14:39] <mbuf> brute4s99, for the next occurrence, just use C-r
[14:39] <mbuf> brute4s99, but, there is no need to do a forward search, if you want to do a search backward
[14:40] <bhavin192> brute4s99, if you do C-M-s once, then you will go to next occurrence, from you will do backward two times in order to reach to the word you want to search
[14:40] <bhavin192> brute4s99, if you do C-M-r then you have to just press C-r once
[14:41] <mbuf> bhavin192, exactly!
[14:41] <brute4s99> oh right. sorry
[14:41] <brute4s99> thanks bhavin192, mbuf
[14:41] <brute4s99> <eom>
[14:41] <mbuf> brute4s99, try the commands slowly, so that you understand what it does
[14:42] <mbuf> If you want to query and replace a word or phrase, you can use:
[14:43] <mbuf> => M-x query-replace <enter> <querystring> <enter> <replacestring>
[14:44] <mbuf> At this juncture, Emacs will be able to accept single characters to act on the matching occurrences of the <querystring>
[14:44] <mbuf> For example:
[14:44] <mbuf> => M-x query-replace <enter> wonderland <enter> dgplug
[14:44] <mbuf> To replace all, you can use:
[14:44] <mbuf> => !
[14:45] <mbuf> In the minibuffer, you should see "Replaced 8 occurrences"
[14:47] <brute4s99> mbuf, it even maintains the Sentence case !
[14:47] <mbuf> brute4s99, :)
[14:47] <brute4s99> s/maintains/retains
[14:47] <mbuf> If you simply want to quit the query-response, you can use:
[14:47] <mbuf> => <enter> or q
[14:48] <mbuf> If you want to replace one at a time, you can use:
[14:48] <mbuf> => <space> or y
[14:48] <mbuf> If you do not want to replace, but, want to move to the next matched instance, you can use:
[14:49] <mbuf> => n
[14:49] <mbuf> 'q' for quit, 'y' for yes, 'n' for no etc.
[14:49] <priyankasaggu119> !
[14:49] <mbuf> next
[14:50] <priyankasaggu119> I have tried the above command. But the message is "Replaced 0 occurrences"
[14:50] <mbuf> If you want to replace the current instance and quit, you can use:
[14:50] <mbuf> => .
[14:51] <mbuf> priyankasaggu119, Which command? Give the full command you typed
[14:51] <brute4s99> !
[14:52] <priyankasaggu119> M-x query-replace <enter>
[14:52] <priyankasaggu119> wonderland <enter>
[14:52] <priyankasaggu119> dgplug
[14:52] <mbuf> priyankasaggu119, at this juncture, Emacs highlights the matched words
[14:52] <mbuf> priyankasaggu119, do you see them highlighted?
[14:53] <priyankasaggu119> No, mbuf
[14:53] <mbuf> priyankasaggu119, are you running these commands in the 11-0.txt file in an Emacs window?
[14:53] <priyankasaggu119> yes mbuf.
[14:54] <mbuf> priyankasaggu119, then you do not have the word 'wonderland' in the file, maybe you already replaced them?
[14:54] <priyankasaggu119> But I tried it with other words also, it says '0' in each case.
[14:54] <mbuf> priyankasaggu119, if you do a forward search for 'wonderland', do you see any matches?
[14:55] <mbuf> next
[14:55] <priyankasaggu119> No, mbuf. I guess now the word is not there
[14:55] <mbuf> priyankasaggu119, if you have already replaced, how will it be there?
[14:56] <brute4s99> for example : => M-x quer-replace gets auto-corrected to => M-x query-replace !
[14:56] <mbuf> The other command options you can try in the query-response juncture are:
[14:56] <priyankasaggu119> mbuf, the very first time, when I tried that command. the message was "0" only
[14:56] <mbuf> => ,
[14:57] <mbuf> The above ',' comma can be used to replace and see the result before moving on the next occurrence
[14:57] <priyankasaggu119> ohk mbuf, i will try. <eof>
[14:58] <mbuf> If you want to move to the previous instance, use:
[14:58] <mbuf> => ^
[14:58] <mbuf> If you want to modify the replacement string, you can use:
[14:58] <mbuf> => E
[14:58] <mbuf> You can also use query-replace with regex using:
[14:58] <mbuf> => C-M-%
[14:59] <mbuf> priyankasaggu119, you are doing something wrong then
[14:59] <mbuf> We will stop here for today.
[14:59] <priyankasaggu119> I restarted emacs. It works now, mbuf.
[15:00] <mbuf> priyankasaggu119, restarting is not a solution; one needs to find out what was the cause
[15:00] <mbuf> priyankasaggu119, of the problem, debug, and not repeat the mistake again
[15:00] <mbuf> priyankasaggu119, now, we will not know what had happened
[15:00] <priyankasaggu119> before that even when I was trying to search for a regex. It was indicating failing in the start of every message in the mini-buffer.
[15:00] <mbuf> priyankasaggu119, then you were not on the 11-0.txt file, maybe.
[15:00] <priyankasaggu119> "failing"
[15:01] <mbuf> priyankasaggu119, yes, if a match fails, the minibuffer will state that.
[15:01] <priyankasaggu119> But I was using the same file, mbuf.
[15:01] <mbuf> Please practice these search commands.
[15:01] <mbuf> priyankasaggu119, as I said, we will not know, as you restarted the application.
[15:01] <mbuf> Our next session will be on Friday at 1930 IST.
[15:01] <mbuf> Roll call
[15:01] <priyankasaggu119> ohk mbuf, next time, I will try to debug first.
[15:01] <brute4s99> Piyush Aggarwal
[15:01] <priyankasaggu119> Priyanka Saggu
[15:01] <shiva> Shiva Saxena
[15:02] <bhavin192> Bhavin Gandhi
[15:02] <storymode7> Mayank Singhal
[15:02] <sandeepK> Sandeep Kumar Choudhary
[15:03] <gutsytechster> Prashant Sharma
----END CLASS----