20:06:04 <FranciscoD> #startmeeting 20:06:04 <zodbot> Meeting started Tue Dec 13 20:06:04 2011 UTC. The chair is FranciscoD. Information about MeetBot at http://wiki.debian.org/MeetBot. 20:06:04 <zodbot> Useful Commands: #action #agreed #halp #info #idea #link #topic. 20:06:22 <FranciscoD> #meetingname fedora-classroom session on VIM 20:06:22 <zodbot> The meeting name has been set to 'fedora-classroom_session_on_vim' 20:06:36 <FranciscoD> http://fedoraproject.org/wiki/Zodbot#Meeting_Functions 20:06:47 <FranciscoD> do have a quick look on how to use zodbot 20:06:53 * nirik hopes topic now will work for you. ;) 20:07:23 <FranciscoD> nirik: meetingname and topic different? 20:07:33 <FranciscoD> meetingname and meetingtopic? 20:07:44 <FranciscoD> #topic prerequisits 20:07:52 <nirik> yeah, topic changes the channel topic. ;) 20:07:59 <nirik> anyhow, do start in. 20:08:09 <FranciscoD> su -c 'yum install vim vim-X11 vim-vimoutliner' 20:08:25 <FranciscoD> please run the command to install the required packages from the fedora repositories 20:08:48 <FranciscoD> if at any point in the class, you have a question, please stop me and ask away :) 20:08:57 <kalpurush> done :) 20:09:20 <thunderbirdtr> Already done :) 20:09:35 <soumyaC> done ! 20:09:41 <yodamaster> ok 20:09:50 <Awes> what about debian users 20:10:14 <v1k1n60> done 20:10:41 <franciscod> crappy network, sorry 20:10:47 <yodamaster> done ! 20:10:55 <chuckf> Awes: should be 'sudo apt-get install vim vim-X11 vim-vimoutliner 20:11:18 <franciscod> thanks chuckf 20:11:27 <thunderbirdtr> 'sudo apt-get install vim vim-X11 vim-vimoutliner' last char please 20:11:43 <franciscod> please use your distro specific commands, all my commands will be on a fedora machine, 20:11:49 <franciscod> most of them are generic though 20:11:54 <franciscod> next: 20:12:01 <franciscod> please download this file to your system: 20:12:04 <franciscod> http://ankursinha.fedorapeople.org/fedora-classroom.txt 20:12:13 <franciscod> its the file we'll work on 20:12:27 * franciscod waits for all to download the file 20:12:40 <v1k1n60> done 20:12:58 <tdiehl> done 20:13:13 <chuckf> got it 20:13:19 <thunderbirdtr> done. 20:13:31 <simonzz> done 20:13:36 <kalpurush> done 20:13:39 <franciscod> okay, open a terminal 20:13:57 <franciscod> cd to the directory you downloaded the file to: cd <~/<directory path> 20:13:58 <yodamaster> ok 20:14:01 <yodamaster> done 20:14:15 <franciscod> #topic command invocation 20:14:35 <FranciscoD> #topic command invocation 20:14:37 <FranciscoD> ah 20:15:03 <FranciscoD> once you're in the directory where the file resides (verify with 'ls' command) 20:15:09 <FranciscoD> vim fedora-classroom.txt 20:15:24 <FranciscoD> that should open the file for you, in the vim editor 20:15:46 * FranciscoD waits for any issues with this step 20:15:56 <kalpurush> done 20:15:59 <tdiehl> done 20:16:01 <kalpurush> open with vim editor 20:16:34 <FranciscoD> okay, press "ZQ" that is a CAPITAL Z followed by a CAPITAL Q 20:16:43 <Awes> (What is the difference between pure Vi and Vim) 20:17:00 <FranciscoD> Awes: i didnt intend to cover that, but vim is basically vi + features 20:17:18 <FranciscoD> I'm going to give you a crash course so you cab begin using vim efficiently in day to day life 20:17:39 <FranciscoD> I will give references at the end that you can read up to learn a lot more 20:17:54 <FranciscoD> okay, so you should be back at the terminal now 20:18:02 <tdiehl> yep 20:18:05 <kalpurush> yap 20:18:06 <FranciscoD> (if you opened the file successfully and hit 'ZQ') 20:18:06 <yodamaster> ok 20:18:19 <jfabian> ready 20:18:23 <kalpurush> it says Entering Ex mode 20:18:46 <FranciscoD> kalpurush: hit escape twice, hit 'ZQ' 20:18:54 <FranciscoD> (you pressed something else ;) ) 20:18:54 <Awes> (what is the Z for Q = Quit) 20:19:04 <FranciscoD> Awes: coming to it, patience :) 20:19:23 <Awes> :) 20:20:00 <tocha> just quit? 20:20:15 <jacobraj> the file quits on ZQ 20:20:24 <kalpurush> +1 jacobraj 20:20:34 <FranciscoD> tocha: yep, you should be back to the terminal now 20:20:48 <tocha> already there 20:20:51 <FranciscoD> okay 20:21:00 <FranciscoD> now, lets copy our file to another name: 20:21:11 <FranciscoD> cp fedora-classroom.txt another-classroom.txt 20:21:32 <FranciscoD> for people who missed out: 20:21:33 <FranciscoD> http://meetbot.fedoraproject.org/fedora-classroom/2011-12-13/fedora-classroom_session_on_vim.2011-12-13-20.06.log.txt 20:21:49 <soumyaC> done ! 20:21:50 <FranciscoD> next: vim -p fedora-classroom.txt another-classroom.txt 20:22:36 <kalpurush> done 20:22:41 <FranciscoD> the '-p' flag opens all the files mentioned in the argument list in separate "tabs" 20:22:42 <soumyaC> FranciscoD, is it same like vsplit ? 20:23:00 <yodamaster> excelent 20:23:02 <FranciscoD> soumyaC: no, you see all your splits at once, tabs overlap each other 20:23:05 <yodamaster> two tabs 20:23:06 <tocha> good! 20:23:06 <FranciscoD> you use one tab at a time 20:23:35 <Awes> beautiful 20:23:41 <FranciscoD> this is handly when you're coding, i keep all my source files open at once ;) 20:23:44 <Awes> How to switch the tabs ? 20:23:50 <jacobraj> how to switch b/w the tabs 20:23:50 <FranciscoD> 'gt' 20:23:54 <FranciscoD> try that 20:23:59 <FranciscoD> gt: next tab 20:24:05 <FranciscoD> gT: previous tab 20:24:12 <FranciscoD> (small t and capital T) 20:24:18 <tocha> nice 20:24:23 <FranciscoD> it goes in a cycle 20:24:36 <kalpurush> oww 20:24:38 <kalpurush> :) 20:24:45 <FranciscoD> if you press 'gT' when you're at the last tab, it comes back to the first.. 20:24:58 <thunderbirdtr> FranciscoD, Is that have another way like using one key ? like "TAB" button ? 20:25:45 <Awes> gt and GT works 20:25:49 <Awes> sorry 20:25:52 <Awes> gt gT 20:26:06 <FranciscoD_> I know ;) 20:26:49 <FranciscoD> okay 20:26:52 <thunderbirdtr> FranciscoD, Is that have another way like using one key ? like "TAB" button ? 20:26:55 <yader> that's cool 20:27:09 <FranciscoD> thunderbirdtr: yeah, you can remap all your keys, 20:27:17 <FranciscoD> i;ll give you a reference on that later :) 20:27:26 <tocha> good 20:27:27 <thunderbirdtr> FranciscoD, Thank you 20:27:32 <FranciscoD> although its suggested to keep the default mappings generally :) 20:27:39 <FranciscoD> okay, so back to the terminal 20:27:52 <FranciscoD> lets go change some text, 20:27:57 <FranciscoD> #topic modes 20:28:07 <FranciscoD> open one of the files: 20:28:12 <FranciscoD> vim fedora-classroom.txt 20:28:27 <kalpurush> done 20:28:28 <FranciscoD> what vim does is, maintain buffers 20:28:38 <FranciscoD> each file is opened in one of these buffers 20:28:59 <FranciscoD> by default, once you open a file, you aren't in "insert" mode 20:30:22 <FranciscoD_> my network is really cross today :/ 20:30:35 <FranciscoD_> continuing 20:30:36 <FranciscoD_> .. 20:30:52 <FranciscoD_> not in insert mode implying, what you type doesnt get inserted as text 20:31:00 <FranciscoD_> for instance, ZQ didn't add ZQ to your document 20:31:34 <FranciscoD_> you are in "command modr" 20:31:48 <FranciscoD_> there are more modes in vim 20:31:56 <FranciscoD_> press ":" (thats a colon) 20:32:31 <kalpurush> done 20:32:43 <FranciscoD_> you will see a colon pop up in the left bottom corner. 20:32:44 <FranciscoD_> you are now in "ex mode" 20:32:58 <FranciscoD_> after colon, hit "w" and press enter 20:34:07 <FranciscoD> ":w" is the command that *w*rites your buffer to file 20:34:15 <FranciscoD> w -> write 20:34:34 <FranciscoD> switching between modes: 20:34:45 <FranciscoD> #topic insert mode 20:35:58 <FranciscoD_> hitting "i" in command mode takes you to insert mode 20:35:58 <FranciscoD_> in this mode, vi is just like notepad 20:36:02 <FranciscoD_> you move around with your keys 20:36:06 <FranciscoD_> arrow keys 20:36:18 <FranciscoD_> you type where you want, you delete what you want 20:36:26 <FranciscoD_> to save, his esc 20:36:32 <FranciscoD_> followed by ":w" 20:36:57 <FranciscoD_> that is: esc to get out of insert mode into command mode, and ":w" to *w*rite your buffer to file 20:37:01 <FranciscoD_> any issues till now? 20:37:20 <Awes> all good 20:37:32 <Southern_Gentlem> except for his internet 20:37:48 <FranciscoD_> yeah man :/ 20:37:59 <FranciscoD_> switched to my cell phone, should be more stable now 20:38:36 <FranciscoD> okay, take a minute to get into insert mode, move around the file a bit 20:38:44 <FranciscoD> then switch between insert and command modes 20:38:49 <FranciscoD> a few times, so you get used to it 20:39:11 * FranciscoD counts 30 in his head 20:39:54 <FranciscoD> question: how many of you use vim like this? in insert mode, like a notepad? :P 20:40:14 <Awes> nope just vi 20:40:22 <FranciscoD> vi or vim? 20:40:24 <Awes> not sure vi has a mode like this 20:40:28 <kalpurush> those who r attending class now :P 20:40:37 <soumyaC> me too vi 20:40:37 <FranciscoD> Awes: whatever I teach here should be valid in vi too 20:40:43 <FranciscoD> these are generic thingys 20:40:44 <thunderbirdtr> both of it 20:40:48 <thunderbirdtr> but mostly vim 20:41:09 <tocha> i use vi 20:41:29 <FranciscoD> okay, now this using insert mode majority of the time is *not* the correct way of using vi/vim 20:41:42 <FranciscoD> it is the *inefficient* way of using vi/vim 20:41:53 <yader> i use gvim :p 20:41:58 <FranciscoD> lol 20:42:03 <FranciscoD> vi/vim/gvim :P 20:42:17 <FranciscoD> yader: all these are valid in gvim btw 20:42:26 <FranciscoD> okay, please come into command mode 20:42:29 <yader> nice :) 20:42:34 <FranciscoD> we're going to explore it 20:42:52 <FranciscoD> #topic running around in command mode 20:43:24 <FranciscoD> okay, now there's something called touch typing 20:43:31 <FranciscoD> (i wont teach you that here :P) 20:43:46 <FranciscoD> here, you practice so you can type with minimal movement of your fingers 20:43:54 <FranciscoD> su -c 'yum install gtypist' 20:44:05 <FranciscoD> gtypist is a tool that teaches you how to touch type correctly 20:44:29 <FranciscoD> on your qwerty keyboards, you'll notice marks on the 'f' and 'j' keys 20:44:33 <FranciscoD> this is called home row 20:44:49 <FranciscoD> the index finger of your left hand goes on f, and of the right hand goes on j 20:45:00 <FranciscoD> and the other fingers to the next keys respectively 20:45:13 <FranciscoD> vim makes is easy for you to work in this position 20:45:27 <FranciscoD> so you can work with minimal movements of your fingers, and therefore efficiently 20:45:33 <FranciscoD> j - move down a line 20:45:40 <FranciscoD> k - move up a line 20:45:47 <FranciscoD> h - move left a character 20:46:00 <FranciscoD> l - move right a character 20:46:03 <FranciscoD> try that 20:46:12 <FranciscoD> see if it works, you have 30 seconds :) 20:46:18 <FranciscoD> any issues, stop me 20:46:22 <kalpurush> done :) 20:46:51 <FranciscoD> next 20:46:55 <FranciscoD> hit 'G' 20:47:01 <FranciscoD> CAPITAL g 20:47:09 <FranciscoD> this takes you to the last line of the file 20:47:16 <FranciscoD> hit 'gg' 20:47:22 <FranciscoD> that is *small* g twice 20:47:29 <FranciscoD> this takes you to the *first* line of the file 20:47:49 <FranciscoD> hit '45G' 20:47:55 <FranciscoD> this takes you to line #45 20:48:03 <FranciscoD> hit 'gg' to get back to the first line 20:48:28 <FranciscoD> any trouble in this part? 20:48:32 <FranciscoD> anyone? 20:48:45 <FranciscoD> move around a little, try it out 20:48:46 <soumyaC> no 20:48:52 * chuckf is good 20:48:59 <FranciscoD> hit '$' 20:49:03 <FranciscoD> takes you to the end of the line 20:49:18 <FranciscoD> hit '0' to go to the beginning of a line 20:49:21 <FranciscoD> thats ZERO 20:49:36 <FranciscoD> hit '10|' to go to column 10 20:49:42 <FranciscoD> thats TEN followed by a PIPE 20:50:11 <FranciscoD> you should see the row, column positioning of the cursor in the right hand bottom corner 20:50:17 <FranciscoD> if you cant, hit 'ctrl g' 20:50:40 <FranciscoD> this will display the file name on the left botton corner, row,col in right bottom corner 20:50:43 <FranciscoD> all okay? 20:50:53 * soumyaC fine 20:50:55 <thunderbirdtr> just gg 20:51:07 <chuckf> yup 20:51:09 <thunderbirdtr> I can't used 20:51:13 <FranciscoD> take your time thunderbirdtr , I'll wait a minute 20:51:24 <FranciscoD> thunderbirdtr: are you in command mode? hit esc twice to confirm 20:51:26 <FranciscoD> then try gg 20:51:40 <thunderbirdtr> I do done 20:51:55 <FranciscoD> okay, now 20:52:05 <FranciscoD> as mentioned earlier, you can use 'i' to enter insert mode 20:52:08 <FranciscoD> and thus insert text 20:52:18 <FranciscoD> now you know how to navigate in command mode, on a line basis 20:53:03 <FranciscoD> now, instead of doing this, we'll use some more navigation shortcuts to make navigation even faster 20:53:19 <FranciscoD> 'w' - moves forward word by word 20:53:28 <FranciscoD> 'b' - moves back word by word 20:53:53 <FranciscoD> 'e' - moves forward word by word too 20:54:02 <FranciscoD> what;s the difference between 'w' and 'e' then 20:54:04 <FranciscoD> anyone? 20:54:15 <FranciscoD> try it, see how to cursor moves and tell me 20:54:26 <thunderbirdtr> e is last char 20:54:29 <thunderbirdtr> w is first one 20:54:32 <chuckf> beginning and end of the word 20:54:42 <tocha> cool 20:57:31 <jfabian> :O 20:58:13 <FranciscoD__> apoligies :$ 20:58:39 <thunderbirdtr> You should need new ISP 20:58:39 <FranciscoD> try 'W' - CAPITAL w 20:58:57 <FranciscoD> lol, it isnt usually this crappy 20:59:06 <FranciscoD> capital W is similar to small w 20:59:16 <FranciscoD> the difference being 'W' ignores punctuation 20:59:31 <FranciscoD> try it 20:59:36 <FranciscoD> similar for 'E' 20:59:41 <FranciscoD> similar for 'B' 21:00:05 <FranciscoD> why move word wise, when you can move SENTENCE wise? 21:00:08 <FranciscoD> ')' 21:00:14 <FranciscoD> moves to the next sentence 21:00:26 <FranciscoD> try it 21:00:48 <FranciscoD> even better! 21:01:00 <FranciscoD> ']' moves forward paragraph wise 21:01:09 <FranciscoD> ( and [ move backwards 21:01:37 <chuckf> ] moves through the entire page for me, not just paragraph 21:01:41 * soumyaC thinks to paste this VIM shortcuts on a sticky note in the screen 21:01:43 <FranciscoD> so, everyone comfortable with navigation in command mode? 21:02:26 <chuckf> } moves by paragraph for me 21:02:45 <soumyaC> ] moves from the whole page 21:02:47 <FranciscoD> chuckf: ah, thanks, my bad 21:03:14 <FranciscoD> { and }, (i didnt realize i had the shift pressed :P) 21:03:21 <FranciscoD> so all okay with navigation? 21:03:27 <thunderbirdtr> Yes . 21:03:38 <FranciscoD> now 21:03:46 <FranciscoD> most vim commands can be prefixed by a number 21:03:54 <FranciscoD> this tells vim how many times to repeat the command 21:04:03 <FranciscoD> so '2{' will take you back 2 paragraphs 21:04:19 <FranciscoD> '5j' will take you down 5 lines etc 21:04:35 <FranciscoD> you dont have to press the same command repeatedly, you can use this instead 21:04:53 <FranciscoD> works with { ( hjklweb 21:05:03 <FranciscoD> ill give you a minute to play with it 21:05:28 <FranciscoD> if moving paragraphs wise isnt quick enough 21:05:45 <FranciscoD> 'ctrl f' moves forward by the screenful 21:05:51 <FranciscoD> 'ctrl b' moves back by the screenful 21:06:06 <FranciscoD> f - *f*orward 21:06:11 <FranciscoD> b - *b* backward 21:06:20 <FranciscoD> e - *e*nd 21:06:27 <FranciscoD> b - *b*egin 21:06:44 <FranciscoD> most commands are like this, to make it easy to recall 21:06:48 <FranciscoD> i - *i*nsert 21:07:13 <FranciscoD> 'ctrl d' moves you down half a page 21:07:18 <FranciscoD> d - *d*own 21:07:29 <FranciscoD> 'ctrl u' moves you back up 21:07:35 <FranciscoD> u - *u*p 21:08:15 <FranciscoD> more on command mode later 21:08:21 <FranciscoD> everyone got a hang of it I hope? 21:08:30 * FranciscoD waits for a response 21:08:35 <thunderbirdtr> all good for me 21:08:52 <yader> are you going to upload the log of this class FranciscoD? 21:08:55 <FranciscoD> its a lot of mappings, but you'll get used to it over time 21:08:59 <simonzz> twisted fingers and twisted brain ;-) 21:09:00 <FranciscoD> yader: yes 21:09:12 <FranciscoD> http://meetbot.fedoraproject.org/fedora-classroom/2011-12-13/fedora-classroom_session_on_vim.2011-12-13-20.06.log.txt 21:09:16 <FranciscoD> here's the log 21:09:25 <yader> thanks 21:09:28 <FranciscoD> simonzz: heh, it isnt that bad ;) 21:09:39 <FranciscoD> next mode, yay! 21:09:40 <FranciscoD> #topic ex mode 21:09:58 <FranciscoD> now, 'ex' itself is an editor 21:10:13 <FranciscoD> it is a 'line editor' which means you can use it to make changes to one line at a time 21:10:25 <FranciscoD> it was used earlier, people do use it nowadays too 21:10:35 <FranciscoD> most unix/linux systems will have the ex util 21:10:58 <FranciscoD> in escape mode, if you press ":" 21:11:03 <FranciscoD> you enter 'ex' mode 21:11:18 <FranciscoD> here, you make modifications to the file line wise 21:11:26 <FranciscoD> so: 21:11:28 <FranciscoD> ':40' 21:11:34 <FranciscoD> that is COLON 40 21:11:38 <FranciscoD> in esc mode 21:11:45 <FranciscoD> should take you to line # 40 21:12:29 <FranciscoD> ':w' *w*rites your buffer to file, like you already know 21:12:42 <FranciscoD> ':wq' - save and *q*uit 21:12:49 <thunderbirdtr> Can we see colon number in the vim ? 21:12:51 <FranciscoD> try that, go to terminal, reopen file 21:13:05 <FranciscoD> thunderbirdtr: sure, i was going to come to that 21:13:19 <thunderbirdtr> I'm waiting ... :) 21:13:20 <FranciscoD> reopen fedora-classroom.txt 21:13:32 <FranciscoD> in command mode, :set nu 21:13:51 <FranciscoD> that is, go to 'ex' mode, 'set nu' followed by enter 21:13:57 <FranciscoD> this should bring up the line numbers 21:14:17 <FranciscoD> thunderbirdtr: did you mean column number? 21:14:33 <thunderbirdtr> Line number ? 21:14:35 <FranciscoD> to remove the line numbers, ':set nonu' 21:14:45 <FranciscoD> yeah, try ':set nu' 21:14:50 <FranciscoD> see if that works 21:14:56 <thunderbirdtr> yes I mean that 21:15:06 <thunderbirdtr> FranciscoD, Thank you 21:15:09 <FranciscoD> everyone okay with showing and hiding line numbers? 21:15:24 <tdiehl> yep 21:15:33 <simonzz> yes 21:15:39 <FranciscoD> now, lets see what line editing can do for us 21:15:52 <FranciscoD> #topic search and replace 21:16:17 <FranciscoD> in command mode, "/<text>" searches *forward* for <text> 21:16:22 <FranciscoD> '?<text>' searches backwars 21:16:31 <FranciscoD> try searching for 'Fedora' 21:16:58 <FranciscoD> hit 'n' (small n) to jump to the next match 21:17:02 <FranciscoD> n - *n*ext 21:17:13 <FranciscoD> 'N' to go to previous match 21:17:33 <FranciscoD> your matches should also get highlighted 21:17:39 <FranciscoD> works for everyone? 21:17:47 <tdiehl> yep 21:18:00 <chuckf> yeah 21:18:06 <simonzz> perfectly 21:18:13 <FranciscoD> if you're searching forward, and hit the end of the file, hitting 'n' will get you to the starting of the file 21:18:17 <FranciscoD> again, in cylic fashion 21:18:24 <FranciscoD> same for first line + N 21:18:40 <FranciscoD> now 21:18:47 <FranciscoD> we've learnt how to search 21:18:53 <FranciscoD> or we havent :D 21:18:58 <FranciscoD> search for 'asdfasfsafad' 21:19:06 <FranciscoD> to unhighlight your 'Fedora's 21:19:18 <FranciscoD> (search for random letters) 21:19:29 <FranciscoD> hit 'gg' 21:19:34 <FranciscoD> then '0' 21:19:38 <FranciscoD> to get to the first letter of the first line 21:19:41 <FranciscoD> this is 'Fedora' 21:19:44 <FranciscoD> all here? 21:19:53 <thunderbirdtr> I see all 21:20:03 <soumyaC> yes 21:20:14 <FranciscoD> hit '*' 21:20:18 <FranciscoD> what happens? 21:20:32 <thunderbirdtr> previous search 21:20:33 <soumyaC> highlights 21:20:39 <tdiehl> highlights previous search 21:20:46 <simonzz> highligts current word 21:20:57 <tdiehl> Aah ok 21:21:31 <FranciscoD> searches for the current word under cursor 21:21:35 <thunderbirdtr> yes 21:21:38 <thunderbirdtr> my bad 21:21:42 <FranciscoD> and takes you to the first match *forward* 21:24:28 <simonzz> oh, and '#' is the opposite => *backwards* 21:25:29 <FranciscoD_> aye 21:25:34 <FranciscoD_> that was next 21:25:41 <FranciscoD_> so, you can either use '?' and '/' 21:25:46 <FranciscoD_> or * and # 21:25:54 <FranciscoD_> notice that '?' and '/' are on the same key 21:26:24 <FranciscoD_> now, search, and *replace* 21:26:31 <FranciscoD_> all, come to command mode 21:26:44 <FranciscoD_> in case you're somewhere else 21:26:44 <thunderbirdtr> next 21:27:04 <FranciscoD_> try this: ':%s/Fedora/Fedora Linux/g' 21:27:06 <FranciscoD_> and tell me what happens 21:27:47 <simonzz> 64 replaces ... 21:28:00 <thunderbirdtr> replaces... 21:28:19 <FranciscoD_> it searched and replaced *all* the occurences of 'Fedora' with 'Fedora Linux' 21:28:26 <FranciscoD_> i'll explain the command 21:28:30 <FranciscoD_> : - ex mode 21:28:36 <FranciscoD_> % - *all* lines 21:28:42 <FranciscoD_> s - search and replace command 21:28:52 <FranciscoD_> /Fedora/ - regex to search 21:29:09 <FranciscoD_> /Fedora Linux/ - regex to be replaced with 21:29:35 <FranciscoD_> g - global: whic implies replace all occurences in each line 21:29:47 <FranciscoD_> hit 'u' 21:29:55 <FranciscoD_> it should *u*ndo all changes 21:30:00 <simonzz> Perhaps the 's' is easier to be memorized as *s*ubstitute here 21:30:11 <FranciscoD_> simonzz: aye 21:30:20 <FranciscoD_> i didnt remember that XD 21:30:40 <FranciscoD_> hit 'u' again, the terminal will blink 21:30:54 <FranciscoD_> and in the left bottom corner, you will get a message saying "already at oldest change' 21:31:12 <FranciscoD_> in one session, you can easily undo as many times as you want 21:31:25 <FranciscoD_> I mean there must be a limit, but its big enough for you to not have to worry about 21:31:45 <FranciscoD_> okay, we'd better hurry 21:32:04 <FranciscoD_> #topic more inserts 21:32:26 <FranciscoD> #topic more inserts 21:32:36 <FranciscoD_> 'I' - insert at starting of current line 21:32:56 <FranciscoD_> 'O' - insert above current line 21:33:06 <FranciscoD_> 'o' - insert above current line 21:33:14 <FranciscoD_> try it out 21:33:16 <FranciscoD_> hit u to undo 21:33:21 <FranciscoD_> 'a' - append 21:33:40 <FranciscoD_> unlike 'i' which brings you in insert on the same character, this takes you to the next char 21:33:47 <FranciscoD_> 'A' - append at end of line 21:34:13 <FranciscoD_> many a time , you want to join paragraphs 21:34:26 <FranciscoD_> 'J' - join current and next sentence 21:34:30 <FranciscoD_> try it, hit u to undo 21:34:39 <FranciscoD> #topic copy paste 21:34:48 <FranciscoD_> now, important ;) 21:35:01 <FranciscoD_> in vim, copying is called 'yanking' 21:35:10 <FranciscoD_> so the command to use will be 'y' 21:35:16 <FranciscoD_> paste is 'p' 21:35:37 <FranciscoD_> paste before is 'P' 21:35:42 <FranciscoD_> CAPITAL p 21:35:46 <FranciscoD_> try this 21:35:48 <FranciscoD_> gg 0 21:35:54 <FranciscoD_> 'yy' p 21:36:14 <FranciscoD_> it should copy the line you were on (yy) and paste it there 21:36:27 <FranciscoD_> if you want to cut use 'd' - *d*elete 21:36:39 <FranciscoD_> you can paste where you want, use your navigation keys 21:36:49 <FranciscoD_> paste, undo etc 21:37:11 <FranciscoD_> d stand for the *d*elete command 21:37:18 <FranciscoD_> the thing is, vim saves it in a buffer 21:37:22 <FranciscoD_> p just gets it from there 21:37:34 <FranciscoD_> since we went into tabs, 21:37:45 <FranciscoD_> :tabedit temp -> opens a new tab named temp 21:38:02 <FranciscoD_> copy a few lines from fedora-classroom.txt, switch to temp using 'gt' and paste it 21:38:05 * FranciscoD_ waits 21:38:16 <FranciscoD_> any issues, let me kniw 21:38:31 <FranciscoD_> I'm going a little fast now, we're already up 1.5 hours :O 21:39:01 <FranciscoD_> go back to the previous tab 21:39:06 <FranciscoD_> this time CUT instead of copy 21:39:14 <FranciscoD_> like 'yy', 'dd' cuts the current line 21:39:20 * FranciscoD_ pauses 21:39:27 <FranciscoD_> thunderbirdtr: on board? 21:39:33 <thunderbirdtr> yes 21:39:35 <thunderbirdtr> I do all 21:39:37 <FranciscoD_> alright 21:39:41 <thunderbirdtr> and listen 21:39:48 <FranciscoD_> now, you'll often want to copy more than i line 21:39:52 <FranciscoD_> rather, generally want to 21:40:01 <FranciscoD_> so, here's how to do it 21:40:14 <FranciscoD_> method #1 21:40:16 <FranciscoD_> 5yy 21:40:27 <FranciscoD_> copies the next five lines from current cursor position 21:40:31 <FranciscoD_> similarly 5dd 21:40:38 <FranciscoD_> method #2 21:40:40 <FranciscoD_> the mark method 21:40:52 <FranciscoD_> navigate to the line you want to begin copying from 21:40:57 <FranciscoD_> lets say '40gg' 21:41:11 <FranciscoD_> or '40G' 21:41:13 <FranciscoD_> both work 21:41:21 <FranciscoD_> ':ma' 21:41:27 <FranciscoD_> will *m*ark this line as 'a' 21:41:48 <FranciscoD_> go to line 60 -> 60G 21:42:01 <thunderbirdtr> :ma I can't do it 21:42:08 <FranciscoD_> thunderbirdtr: it wont say anthing 21:42:10 <thunderbirdtr> Argument required 21:42:25 <FranciscoD_> oh, no ":" sorry 21:42:34 <FranciscoD_> its a command mode thing, not an ex mode thing 21:42:36 <FranciscoD_> thunderbirdtr: ^ 21:42:41 <thunderbirdtr> :) don 21:42:42 <FranciscoD_> 40G, followed by ma 21:42:43 <thunderbirdtr> done .. 21:42:47 <FranciscoD_> go to 60 21:42:49 <FranciscoD_> 60G 21:43:01 <thunderbirdtr> yes .. 21:43:04 <FranciscoD_> y + ' + a -> y followed by single quote followed by a 21:43:13 <FranciscoD_> this says: *y*ank from marker a 21:43:39 <FranciscoD_> you'll get a message that says: 21 lines yanked 21:43:49 <thunderbirdtr> just min please 21:43:54 * FranciscoD_ waits 21:44:11 * FranciscoD_ notes that we have 17 more minutes 21:44:22 <FranciscoD_> while i wait, any issues anyone? 21:44:34 <chuckf> it doesn't seem to be working here 21:44:51 <FranciscoD_> chuckf: press escape twice, retry 21:44:55 <simonzz> ma doesn't work 21:45:05 <FranciscoD_> simonzz: ^ 21:45:08 <chuckf> ma then go to 60 then ya 21:45:16 <FranciscoD_> chuckf: y'a 21:45:22 <FranciscoD_> y + ' + a -> y followed by single quote followed by a 21:45:29 <FranciscoD_> there's a single quote 21:45:39 <chuckf> ah, that fixed it 21:45:43 <FranciscoD_> great! 21:45:53 <FranciscoD_> try CUTTING instead of COPYING 21:45:57 <FranciscoD_> (use d instead of y' 21:45:59 <FranciscoD_> ) 21:46:15 <FranciscoD_> i mean (d + ' + a) 21:46:40 <FranciscoD_> keep pasting in the other tab to confirm it works ;) 21:46:50 <FranciscoD_> that will also get you used to tab changing 21:47:12 <FranciscoD_> all good? 21:48:08 <FranciscoD_> okay, 'gg + 0' to go to the first word of our document 21:48:17 <FranciscoD_> i want to replace 'Fedora' by 'Linux' 21:48:27 <FranciscoD_> one way is to go into INSERT mode and do this 21:48:33 <FranciscoD_> but that is *inefficient* 21:48:39 <FranciscoD_> 'cw' 21:48:45 <FranciscoD_> is for *c*hange word 21:48:56 <FranciscoD_> remember that 'w' was for next word 21:49:15 <FranciscoD_> so, if you're at the beginning of a word, and you hit 'cw', the word gets removed 21:49:24 <FranciscoD_> and you can type in its place in insert mode 21:49:28 <FranciscoD_> works for all? 21:49:35 <chuckf> yup 21:49:35 <thunderbirdtr> I do 21:49:51 <FranciscoD_> if you hit '2cw', the next *2* words get replaced! 21:50:00 <FranciscoD_> similarly '2cb' 21:50:01 <FranciscoD_> etc 21:50:12 <FranciscoD_> try it out 21:50:45 <FranciscoD_> another tiny command 21:50:51 <FranciscoD_> f - *f*ind 21:50:56 <FranciscoD_> 'fr' 21:51:04 <FranciscoD_> will take you to the next occurence of the letter 'r' 21:51:12 <FranciscoD_> F - takes you backwards 21:51:34 <FranciscoD_> '2fr' takes you to the second occurence of 'r' from current cursor position 21:51:37 <FranciscoD_> try it out 21:52:09 <FranciscoD_> not surprisingly, 'cfr' removes stuff till the first occurence of 'r' 21:52:16 <tocha> gotta go now. Bye and thanks 21:52:26 <FranciscoD_> bye 21:52:29 <FranciscoD_> also try: '2cfr' 21:52:33 <FranciscoD_> see what happens 21:53:26 <FranciscoD_> youll get a hang of how you can mix commands 21:53:36 <FranciscoD_> all okay? 21:53:42 <thunderbirdtr> Good 21:53:49 <chuckf> yup 21:53:57 <FranciscoD_> now to replace *one* character, use 'r' 21:53:58 <simonzz> yes 21:54:11 <FranciscoD_> so if i want to make 'Fedora' -> 'Zedora', 21:54:17 <FranciscoD_> i take my cursor to the 'F' 21:54:19 <FranciscoD_> and press rz 21:54:23 <FranciscoD_> rather rZ 21:54:27 <FranciscoD_> try that 21:54:33 <FranciscoD_> u to undo 21:54:53 <FranciscoD_> so youve noticed how easy it is to modify text *out* of insert mode 21:54:58 <FranciscoD_> yes? 21:55:10 <thunderbirdtr> sure 21:55:13 <simonzz> vi is somehow fascinating 21:55:21 <FranciscoD_> it sure is 21:55:25 <FranciscoD_> one final topic 21:55:35 <FranciscoD> #topic marcos 21:55:40 <FranciscoD_> okay 21:55:47 <FranciscoD_> ':tabedit temp123' 21:55:54 <FranciscoD_> to open a new tab 21:56:15 <FranciscoD_> lets say, i want you to number this file, 1 to 100, on each lines 21:56:18 <FranciscoD_> *line 21:56:22 <FranciscoD_> how would you do it? 21:56:27 <FranciscoD_> anyone? 21:56:44 <chuckf> ask you how to do it? 21:56:47 <chuckf> :D 21:56:48 <FranciscoD_> chuckf: lol 21:57:00 <FranciscoD_> one way is as always: INSERT mode 21:57:08 <FranciscoD_> but thats not the vim way ;) 21:57:18 <FranciscoD_> in the new tab, write -> 1 21:57:27 <FranciscoD_> and come out of insert mode to command mode 21:57:39 <FranciscoD_> (hit escape) 21:57:49 <FranciscoD_> now, your cursor should be at 1 21:57:55 <FranciscoD_> hit 'ctrl a' 21:58:01 <FranciscoD_> what happens? 21:58:02 <FranciscoD_> anyone? 21:58:13 <chuckf> increases to 2 21:58:17 <FranciscoD_> nice 21:58:20 <FranciscoD_> hit 'ctrl x' 21:58:23 <FranciscoD_> what happens now? 21:58:26 <FranciscoD_> hit it a few times 21:58:51 <simonzz> +/- 1 21:58:55 <FranciscoD_> aye 21:58:57 <chuckf> nifty, decreases 1 21:59:00 <FranciscoD_> get it back to 1 ;) 21:59:14 <FranciscoD_> press q 21:59:30 <FranciscoD_> a message saying 'recording' will pop up in the bottom left 21:59:49 <FranciscoD_> then, do the following: 21:59:58 <FranciscoD_> yank the current line -> yy 22:00:09 <FranciscoD_> paste it below -> p 22:00:18 <FranciscoD_> hit 'ctrl a' to increase it 22:00:27 <FranciscoD_> ah, missed someting 22:00:31 <FranciscoD_> 'qa', not just q 22:00:47 <FranciscoD_> q -> recording; 'qa' means record and save in 'a' 22:01:15 <FranciscoD_> after hitting ctrl a, it increases to 2, hit 'q' again to STOP recording 22:01:22 * FranciscoD_ waits: this ones a little tricky 22:02:23 <FranciscoD_> now, since you recorded in 'a' 22:02:30 <FranciscoD_> we can invoke 'a' 22:02:53 <FranciscoD_> on the second line, where you have '2', his '@a' 22:03:09 <FranciscoD_> all this does is repeat the sequence of commands you had *recorded* in 'a' 22:03:15 <FranciscoD_> you should get 3 on the next line 22:03:27 <FranciscoD_> thunderbirdtr: chuckf : simonzz : let me know if you get stuck 22:03:40 <simonzz> all fine 22:03:44 <FranciscoD_> great 22:03:55 <chuckf> I'm good 22:03:59 <FranciscoD_> great 22:04:02 <FranciscoD_> thunderbirdtr: :P ? 22:04:03 <thunderbirdtr> done 22:04:09 <FranciscoD_> ah! awesome 22:04:14 <thunderbirdtr> Should you ask :)) 22:04:19 <FranciscoD_> now, we dont want to hit '@a' 100 times either ;) 22:04:28 <FranciscoD_> so in true vi/vim/gvim style, 22:04:38 <FranciscoD_> we go '100@a' with cursor on '3' 22:04:46 <FranciscoD_> result anyone? :) 22:04:58 <chuckf> 103 22:04:58 <simonzz> wow 22:05:18 <thunderbirdtr> I have 1,2,3,4,5,6... line by line :P 22:05:21 <FranciscoD_> remember u to undo this entire thing ;) 22:05:26 <FranciscoD_> great, so we covered macros 22:05:33 <FranciscoD_> we're 2 hours +, so I'll end here 22:05:48 <FranciscoD_> but I'll take up follow up classes with more advanced stuff asap 22:06:00 <FranciscoD_> i hope you guys learnt that vim is way more than notepad 22:06:00 <simonzz> That would be great 22:06:09 <thunderbirdtr> Awsome 22:06:09 <FranciscoD_> try 'vimtutor' 22:06:17 <FranciscoD_> its a tutor that comes with vim 22:06:21 <FranciscoD_> it'll let you practice a bit 22:06:23 <simonzz> command :help is helpful as well 22:06:26 <FranciscoD_> aye 22:06:31 <FranciscoD_> :help y 22:06:42 <FranciscoD_> will open the help for *y*ank for example 22:06:57 <thunderbirdtr> Well I like to use --help / man help and FranciscoD Guides :)) 22:06:58 <FranciscoD_> sometimes beginners find it difficult to understand :help text though 22:07:05 <FranciscoD_> heh :) 22:07:13 <FranciscoD_> there's a book if you want to buy 22:07:26 <FranciscoD_> "learning the vi and vim editors" 22:07:30 <FranciscoD_> it has a *lot* of info 22:07:44 <FranciscoD> #topic references 22:07:50 <FranciscoD_> 1. man page ;) 22:07:53 <FranciscoD_> 2. :help 22:07:57 <FranciscoD_> 3. google 22:08:01 <FranciscoD_> 4. 'vi and vim editors' 22:08:09 <FranciscoD_> last: play with it! 22:08:17 <FranciscoD_> okay, ending class 22:08:21 <thunderbirdtr> 5. Ask questions 22:08:22 <thunderbirdtr> :D 22:08:22 * FranciscoD_ asks all to check out http://ask.fedoraproject.org 22:08:27 <FranciscoD_> thunderbirdtr: ^ ;) 22:08:32 <FranciscoD_> for queries, hop on to ask 22:08:38 <FranciscoD> #endmeeting