happypeter / peter-vim

My ~/.vim/
45 stars 26 forks source link

happyvim 课程素材 #6

Open happypeter opened 9 years ago

happypeter commented 9 years ago
happypeter commented 9 years ago

block comment/uncomment can not live withou

happypeter commented 9 years ago

https://code.tutsplus.com/courses/venture-into-vim

happypeter commented 9 years ago

1 00:00:00,000 --> 00:00:04,598 hello everybody, this is Peter here

2 00:00:04,848 --> 00:00:12,051 and today let's start our study of vim

3 00:00:12,301 --> 00:00:15,650 the best editor that ever made

4 00:00:15,900 --> 00:00:19,400 so let's just start at the very beginning, and

5 00:00:19,650 --> 00:00:24,938 have a look at how to open a file with vim

6 00:00:25,188 --> 00:00:27,818 it's like this, so you type vim

7 00:00:28,068 --> 00:00:33,739 you see filename, then you just press enter

8 00:00:34,139 --> 00:00:36,270 and here we are

9 00:00:36,520 --> 00:00:39,358 so let's quit... quit

10 00:00:39,608 --> 00:00:42,910 just capital z, z, twice

11 00:00:43,160 --> 00:00:50,503 OK, let's quit vim, but of course that is not all you need to know

12 00:00:50,753 --> 00:00:54,288 not all the ways how you can open sth with vim

13 00:00:54,538 --> 00:00:56,866 you can also use this this way

14 00:00:57,116 --> 00:00:59,838 like vim, and "newfilename"

15 00:01:00,088 --> 00:01:04,250 I mean, vim will create a new file for you

16 00:01:04,500 --> 00:01:08,824 like this, and you can also type sth here

17 00:01:09,074 --> 00:01:16,510 I will show you how to edit a file in vim later

18 00:01:16,760 --> 00:01:23,847 so like any powerful unix tool,

19 00:01:24,097 --> 00:01:27,423 you can start vim with lots of options

20 00:01:27,673 --> 00:01:31,371 and you can check all the options this way

21 00:01:31,621 --> 00:01:35,736 the option I love is sth like this

22 00:01:35,986 --> 00:01:39,486 remote and a few others

23 00:01:39,736 --> 00:01:46,463 but that's not what we are going to talk in this episode

24 00:01:46,986 --> 00:01:48,159 we will talk about (them) later

25 00:01:48,130 --> 00:01:51,340 so I, I think, ahm...

26 00:01:51,590 --> 00:02:01,231 let's... why not stop here, and we'll check how to do things later.

27 00:02:01,481 --> 00:02:03,725 so have a good day, bye!

happypeter commented 9 years ago

1 00:00:00,000 --> 00:00:02,571 hello everybody

2 00:00:02,821 --> 00:00:05,694 um...this is Peter here... peter again

3 00:00:05,944 --> 00:00:13,955 so today we are going to explore more powerful stuff about ...

4 00:00:14,255 --> 00:00:19,691 about vim... the best editor that ever, you know ...created

5 00:00:19,941 --> 00:00:24,474 um ... so, let's start vim

6 00:00:23,691 --> 00:00:31,370 ah... we are going to create a new file named hello.c and within this file

7 00:00:31,381 --> 00:00:37,036 now what I want to talk about here is when you start vim

8 00:00:37,100 --> 00:00:41,448 you directly come into the "normal mode"

9 00:00:40,591 --> 00:00:45,140 so, you may wonder what the normal mode means

10 00:00:45,812 --> 00:00:52,315 if you don't know normal mode means. Now I can tell you, it's just ...

11 00:00:52,361 --> 00:00:57,516 when you start vim, vim directly take(s) you to normal mode

12 00:00:58,305 --> 00:01:05,248 and now, you can try to type something, like 'd' and 'c'

13 00:01:06,038 --> 00:01:08,081 Ah, you type something but nothing happened

14 00:01:09,041 --> 00:01:11,657 So, you may feel strange here,

15 00:01:11,187 --> 00:01:15,860 but this is actual not bug of vim

16 00:01:17,728 --> 00:01:19,737 but rather it's a nice feature of vim.

17 00:01:19,987 --> 00:01:24,056 it means vim has something called "modes"

18 00:01:24,306 --> 00:01:31,649 so let's check how vim modes works

19 00:01:31,899 --> 00:01:35,155 you just type help, "h" stands for "help"

20 00:01:35,405 --> 00:01:39,869 help vim-modes, OK?

21 00:01:40,119 --> 00:01:44,211 so you can see there are many modes here... many modes

22 00:01:44,461 --> 00:01:49,343 but most ... now in this screencast I want to talk about really

23 00:01:49,593 --> 00:01:51,827 only two of those modes

24 00:01:52,077 --> 00:01:53,731 two most important one(s)

25 00:01:53,981 --> 00:01:58,259 one is normal mode, the other one is I think...

26 00:01:58,509 --> 00:02:00,465 insert mode, like this

27 00:02:00,715 --> 00:02:07,896 so when you first come into ah...

28 00:02:08,146 --> 00:02:14,792 into vim, ah... you first go into normal mode

29 00:02:15,042 --> 00:02:17,300 normal mode also is called command mode

30 00:02:17,550 --> 00:02:22,060 which means everything you type here will be considered as a command

31 00:02:22,310 --> 00:02:27,029 and like 'x' for deleting one word(shall be a character)

32 00:02:27,279 --> 00:02:33,763 and there are also some other commands that can take you into insert mode

33 00:02:34,013 --> 00:02:37,513 like the most often used one is 'i'

34 00:02:37,763 --> 00:02:41,100 press 'i', and vim will go into insert mode

35 00:02:41,350 --> 00:02:50,783 and you can see in the lower left corner of this screen

36 00:02:51,033 --> 00:02:53,314 you see a "insert"

37 00:02:53,564 --> 00:02:56,913 insert, that means vim is now in insert mode

38 00:02:57,163 --> 00:02:59,281 in insert mode, you can generally type something

39 00:02:59,531 --> 00:03:02,579 like "sss", whatever you type here

40 00:03:02,829 --> 00:03:11,890 will be considered as some visible characters, will show up eventually into your file

41 00:03:12,140 --> 00:03:18,089 ah... in your file created, but when you press "esc"

42 00:03:18,339 --> 00:03:20,202 you go back normal mode again

43 00:03:20,452 --> 00:03:25,357 now whatever you type here, as we already mentioned, will be considered as command(s)

44 00:03:25,607 --> 00:03:27,052 like you type 'x'

45 00:03:27,302 --> 00:03:35,156 then ah... you delete one word(shall be one character) rather than insert "x" into your file

46 00:03:35,406 --> 00:03:38,871 so that is the difference, as you type "dd", so "dd", whole line

47 00:03:39,121 --> 00:03:42,621 as you type 'u', it means undo

48 00:03:42,871 --> 00:03:47,161 you can type "ctrl + r", means redo

49 00:03:47,411 --> 00:03:52,618 anyway, don't worry if you can not remember all these things

50 00:03:52,868 --> 00:03:54,986 we will talk about these in details later

51 00:03:55,236 --> 00:04:00,489 anyway in this talk, I just want you know

52 00:04:00,739 --> 00:04:05,899 vim has modes and most important two modes I want you know

53 00:04:06,149 --> 00:04:07,943 here is just two

54 00:04:08,193 --> 00:04:11,356 normal mode and insert mode

55 00:04:11,606 --> 00:04:19,529 so, you still remember how to go into insert mode? you type 'i'

56 00:04:19,779 --> 00:04:30,118 and like this, you press "Esc" and you go back to normal mode

57 00:04:30,368 --> 00:04:32,324 normal mode is also called command mode

58 00:04:32,574 --> 00:04:36,805 which means you type everything as commands

59 00:04:37,055 --> 00:04:40,961 so this is all I want to talk about here

60 00:04:41,211 --> 00:04:45,977 I hope you are not confused, but anyway

61 00:04:46,227 --> 00:04:49,622 it doesn't matter. we will talk about more later

62 00:04:49,872 --> 00:04:55,822 so have a good day. bye

happypeter commented 9 years ago

1 00:00:00,000 --> 00:00:02,926 uh... good afternoon everybody

2 00:00:03,176 --> 00:00:10,054 one of the most obvious problems of my earlier screencasts is that

3 00:00:10,304 --> 00:00:19,598 is that... the way I talk. I generally think it feels boring

4 00:00:19,848 --> 00:00:23,174 to make screencasts and just talk to myself

5 00:00:23,424 --> 00:00:25,844 and later I found it was wrong

6 00:00:26,094 --> 00:00:32,972 and actually I should pretend you are just by my side and we talk like friends

7 00:00:33,222 --> 00:00:42,910 later screencasts made this way shall be better anyway

8 00:00:43,160 --> 00:00:46,765 and today ah... of course with no suprise

9 00:00:47,015 --> 00:00:50,039 we continue to talk about vim

10 00:00:50,289 --> 00:00:56,517 we start vim, and now we know vim has many modes

11 00:00:56,767 --> 00:01:01,765 help vim modes. and the most important ones

12 00:01:02,015 --> 00:01:05,155 of course, are normal mode

13 00:01:05,405 --> 00:01:12,539 and insert mode

14 00:01:12,789 --> 00:01:17,555 insert mode, this one yeah!

15 00:01:17,805 --> 00:01:31,858 insert mode, but today I'd like to talk more about why vim has these modes

16 00:01:32,108 --> 00:01:35,364 can we just go without modes?

17 00:01:35,614 --> 00:01:38,197 and the reason is like this

18 00:01:38,447 --> 00:01:42,330 usually in the most other editors you don't have modes

19 00:01:42,580 --> 00:01:47,439 you just work in one mode that is as it looks

20 00:01:47,689 --> 00:01:50,132 and we call it insert mode, like vim insert mode

21 00:01:50,382 --> 00:01:52,106 you always stay in insert mode

22 00:01:52,356 --> 00:02:00,186 then sometimes you need some shortcut to make you work more efficiently

23 00:02:00,436 --> 00:02:03,623 like you want delete one word

24 00:02:03,873 --> 00:02:11,564 maybe you press "ctrl+d" or "ctrl+w"

25 00:02:11,814 --> 00:02:14,513 and sometimes you need to do something more powerful

26 00:02:14,763 --> 00:02:23,639 and you need to use like "ctrl +command +s"

27 00:02:23,889 --> 00:02:29,490 and "ctrl +option +command+s" , something like these

28 00:02:29,740 --> 00:02:36,363 you can't avoid these, if you really want some more powerful shortcuts

29 00:02:36,613 --> 00:02:42,656 that's what is happening in some other editors all the time

30 00:02:42,906 --> 00:02:51,549 it can do your work, but the problem is you struggle to use your fingers

31 00:02:51,799 --> 00:02:55,404 and it feels really awful and it is not so efficient

32 00:02:55,654 --> 00:02:56,193 and that's the problem.

33 00:02:56,443 --> 00:03:01,139 that's why vim has its modes. and its normal mode is command mode

34 00:03:01,389 --> 00:03:09,823 like this command mode. in this way you can do things much much simpler

35 00:03:10,073 --> 00:03:15,744 and of course with price of have (having) different modes

36 00:03:15,994 --> 00:03:19,158 that's a good price to pay

37 00:03:19,408 --> 00:03:22,246 it's really rewarding. so no problem

38 00:03:22,496 --> 00:03:25,288 at least I like it so much

39 00:03:25,538 --> 00:03:28,074 and you can use "xx"

40 00:03:28,324 --> 00:03:36,294 and "dd" to delete one word(one line). you no longer need to struggle to your fingers

41 00:03:36,544 --> 00:03:43,678 uh... painfully, so that's why vim has modes

42 00:03:43,928 --> 00:03:49,413 and of course until now you still only need to know two modes

43 00:03:49,663 --> 00:03:53,198 insert mode and normal mode

44 00:03:53,448 --> 00:04:00,373 so that's why vim has many modes

45 00:04:00,623 --> 00:04:10,402 ok, let's call it a day. talk to you later. bye

happypeter commented 9 years ago

1 00:00:00,000 --> 00:00:05,666 ladies and gentlemen, boys and girls. now we are in vim

2 00:00:05,916 --> 00:00:11,076 so today I want to talk about a little bit

3 00:00:11,326 --> 00:00:16,951 why vim takes us first directly into normal mode

4 00:00:17,201 --> 00:00:26,842 uh..., the fact is that in the normal mode you can actually modify your stuff fair easily

5 00:00:27,092 --> 00:00:31,742 and efficiently. if you are in the insert mode, the movement,

6 00:00:31,992 --> 00:00:41,982 uh..., will be, will have to use arrow key or something like this

7 00:00:42,232 --> 00:00:48,483 it won't be so efficient. so in normal mode, everything can be done

8 00:00:48,733 --> 00:00:56,842 much much simpler. uh..., so and in the career of a programmer

9 00:00:57,092 --> 00:01:05,178 most of time will be spend on changing things rather than inserting things

10 00:01:05,428 --> 00:01:11,308 inserting words, that's why normal mode first

11 00:01:11,558 --> 00:01:15,627 so, now we are in normal mode

12 00:01:15,877 --> 00:01:20,295 let's see how to move around in the normal mode

13 00:01:20,545 --> 00:01:31,533 and first let's check the help file "help motion.txt"

14 00:01:31,783 --> 00:01:38,592 uh..., if you want detailed information about how to move around

15 00:01:38,842 --> 00:01:44,467 and also something about operators which we will talk about

16 00:01:44,717 --> 00:01:53,546 maybe later in our next talk. you can check the manual here

17 00:01:53,796 --> 00:01:59,211 but if everything can be found in the manual

18 00:01:59,461 --> 00:02:02,555 what's the point of our screencasts?

19 00:02:02,805 --> 00:02:14,397 our screencast is made so as to you don't need to read all the stuff in the manual

20 00:02:14,647 --> 00:02:22,222 because in the manual there will be lot of details that... ah... peter wants you to learn later

21 00:02:22,472 --> 00:02:27,702 not now. some of the details are really important

22 00:02:27,952 --> 00:02:35,318 but i think it for beginners it is better to leave them alone

23 00:02:35,568 --> 00:02:41,286 so you just need to follow peter and check out the basic stuffs and

24 00:02:41,536 --> 00:02:44,374 build up your knowledge base step by step

25 00:02:44,624 --> 00:02:48,298 later you will get to know all the basic things. you can say

26 00:02:48,548 --> 00:02:52,989 " em... how can i do things a little bit more efficiently "

27 00:02:53,239 --> 00:02:58,608 then you can check the manual and get all the powerful stuff out of it

28 00:02:58,858 --> 00:03:05,202 so, let's talk about motion, let's talk about how to move around in vim

29 00:03:05,452 --> 00:03:10,961 so as you can see, uh... we can move left

30 00:03:11,211 --> 00:03:15,071 this way, move right. this way, move up

31 00:03:15,321 --> 00:03:21,572 sorry, move down, move up, it's just 'h', 'j', 'k' , 'l'

32 00:03:21,822 --> 00:03:27,215 and this is the basic movement and can we just move one word

33 00:03:27,465 --> 00:03:30,953 a time just type 'wwww'

34 00:03:31,203 --> 00:03:42,029 can we just move, uh..., the other way, like move half a page down

35 00:03:42,279 --> 00:03:48,693 use "ctrl +d ", I think. I don't use "ctrl +d " very often

36 00:03:48,943 --> 00:03:52,246 because I just love to move line by line

37 00:03:52,496 --> 00:03:58,121 every time if you use "ctrl + d" and move inside big file, i got confused

38 00:03:58,371 --> 00:04:04,367 I lost my track. en, that's not so good

39 00:04:04,617 --> 00:04:09,452 uh..., how you move inside big files

40 00:04:09,702 --> 00:04:13,608 let's make a big file. you don't need to know what I'm doing here

41 00:04:13,858 --> 00:04:15,443 I am just making a big file

42 00:04:15,693 --> 00:04:20,992 how can we move very quickly inside a big file

43 00:04:21,242 --> 00:04:28,492 I use search. It's maybe called "moving by searching"

44 00:04:28,742 --> 00:04:36,503 you do it this way. if I want move somewhere where I can find another main

45 00:04:36,753 --> 00:04:40,242 uh..., I can do it this way

46 00:04:40,492 --> 00:04:45,861 type "main", then press "enter", and now "nnn"

47 00:04:46,111 --> 00:04:51,178 so, usually if I want to move inside big files

48 00:04:51,428 --> 00:04:54,847 I do this way rather than just type "ctrl + d"

49 00:04:55,097 --> 00:05:07,014 for moving down half page. and "ctrl +u " for moving up half page also

50 00:05:07,264 --> 00:05:10,056 I don't use them very often

51 00:05:10,306 --> 00:05:13,469 so, that's the basic movement

52 00:05:13,719 --> 00:05:25,749 and..., so let's stop here. and talk to you later, bye

happypeter commented 9 years ago

1 00:00:00,000 --> 00:00:12,005 hi, you, good afternoon. so, now, I am not feeling very uh... very great

2 00:00:12,255 --> 00:00:18,251 uh... since I have a little bit stomachache

3 00:00:18,501 --> 00:00:25,008 uh... my stomach hurts a bit. it's OK, not so horrible

4 00:00:25,258 --> 00:00:29,257 uh... you know, human beings are just animals

5 00:00:29,507 --> 00:00:34,249 except that we can think, we talk, we work

6 00:00:34,499 --> 00:00:41,494 uh..., so when our life get messy . I think at least for me it is true

7 00:00:41,494 --> 00:00:47,972 I tend to think about doing something that make some sense

8 00:00:48,222 --> 00:00:56,541 so it can probably set our heart peaceful and put us on the right track

9 00:00:56,791 --> 00:01:03,692 so, and doing technology is one of things do make me feel peaceful

10 00:01:03,942 --> 00:01:08,406 because technology is just something fun, it's no big deal, right?

11 00:01:08,656 --> 00:01:15,511 just like this, OK, so if you don't mind

12 00:01:15,761 --> 00:01:20,341 let's start, continue our study of vim

13 00:01:20,591 --> 00:01:26,819 OK, let's see what we can do, let's start vim

14 00:01:27,069 --> 00:01:28,909 check what's in this

15 00:01:29,159 --> 00:01:31,022 uh... it's bullshit, OK

16 00:01:31,272 --> 00:01:40,496 we don't need. OK, so, now let's create a new file

17 00:01:40,746 --> 00:01:47,485 we don't always create '.c' file, we can create any file

18 00:01:47,735 --> 00:01:53,824 OK, and maybe we type something, go to insert mode and type something

19 00:01:54,074 --> 00:01:57,005 I'm sure you now know how to go to insert mode

20 00:01:57,255 --> 00:02:01,789 and maybe you already read the help file and

21 00:02:02,039 --> 00:02:12,493 you know the difference between switching among those modes, normal mode and insert mode

22 00:02:12,743 --> 00:02:16,185 and a bit more, other modes

23 00:02:16,435 --> 00:02:24,637 so, today I want to talk about is still motions

24 00:02:24,887 --> 00:02:26,262 motions, how to move around

25 00:02:26,512 --> 00:02:32,323 let's say, we have "hello world"

26 00:02:32,573 --> 00:02:37,942 and how to, you know how to move to the beginning of this line

27 00:02:38,192 --> 00:02:45,280 it's zero. and end, dollar. zero, dollar

28 00:02:45,530 --> 00:02:58,004 zero, I'm sorry. uh... so, you know how to move one word a time. "ww" and

29 00:02:58,254 --> 00:03:03,507 now, guess how to move two words a time. it's '2w'

30 00:03:03,757 --> 00:03:05,690 I'm sorry, it's not clear

31 00:03:05,940 --> 00:03:19,854 it's like this. "hello world peter is your friend", move to the beginning , it's three 'w'

32 00:03:20,104 --> 00:03:25,148 '3w' and maybe '2w', like this

33 00:03:25,398 --> 00:03:33,322 and now guess how to move two lines down one time

34 00:03:33,572 --> 00:03:35,737 in one go, it's just,

35 00:03:35,987 --> 00:03:39,382 we go to the... first go to the top of this file

36 00:03:39,632 --> 00:03:44,560 done by "gg", and two 'j'

37 00:03:44,810 --> 00:03:49,970 two 'j', it's "gg"

38 00:03:50,220 --> 00:03:59,096 two 'j' and "gg", three 'j' and it's like this

39 00:03:59,346 --> 00:04:09,382 now, you can see it's just a number with a motion, and that will just do

40 00:04:09,632 --> 00:04:15,164 what you want in a very obvious and maybe a little bit childish way

41 00:04:15,414 --> 00:04:18,624 and it's the motion

42 00:04:18,874 --> 00:04:27,424 uh... but what I want talk about here is the general rule of vim operation

43 00:04:27,674 --> 00:04:35,319 it's one operator and then followed with a motion

44 00:04:35,569 --> 00:04:40,706 let's check the general rule. first you don't know what the operator is maybe

45 00:04:40,806 --> 00:04:45,350 so let's check what operator is, let's check maybe help operators, I'm not sure

46 00:04:45,600 --> 00:04:52,804 help operators, help operator, OK I think we are luck

47 00:04:53,054 --> 00:04:58,864 operators are some things like change, like 'c', change a word

48 00:04:59,114 --> 00:05:02,835 like "d", delete a word, "yank",something like copy

49 00:05:03,085 --> 00:05:08,709 yank means copy, and lots of other more

50 00:05:08,959 --> 00:05:14,189 those are... I think those are operators, but currently we focus on something simple

51 00:05:14,439 --> 00:05:16,116 like change and delete

52 00:05:16,366 --> 00:05:27,262 uh... let's show how to work using operators and motions the same time. OK

53 00:05:27,512 --> 00:05:36,573 like, let's try to delete two words. in one go, it is 'd' two 'w'. OK

54 00:05:36,823 --> 00:05:42,750 uh... undo this thing. 'd' three word

55 00:05:40,573 --> 00:05:52,804 OK, and how can we delete from this line to the end of this file

56 00:05:53,054 --> 00:05:58,237 'd' then the motion 'G' to the end of file

57 00:05:58,487 --> 00:06:00,258 yeah, easy, yeah

58 00:06:00,508 --> 00:06:05,436 it's how to delete from this line to top of this file. 'd' and "gg"

59 00:06:05,686 --> 00:06:13,214 OK, so let's try d (delete) four word

60 00:06:13,464 --> 00:06:24,940 OK, I think you can see the rules, very, it's very childish, but it is very convenient.

61 00:06:25,190 --> 00:06:29,979 so, let's see how to delete two lines. let's go up, go up

62 00:06:30,229 --> 00:06:34,879 delete two lines, 'd' two 'j', two lines

63 00:06:35,129 --> 00:06:42,889 like three lines, anyway, it's 'd' two 'j', like this

64 00:06:43,139 --> 00:06:49,693 so, if you want know more, if peter here is not giving you very clear explanation

65 00:06:49,943 --> 00:06:58,656 you can check more in documentation yourself. it's like help motions. motions, I think

66 00:06:58,906 --> 00:07:09,523 motions dot txt, you can get things here. how to move around and how to use operators with motions

67 00:07:09,773 --> 00:07:21,783 uh... you know what I mean by talking about motions, motions, we can check motions

68 00:07:22,033 --> 00:07:31,349 characters motions

69 00:07:31,599 --> 00:07:36,133 uh... it doesn't so matter. but uh...

70 00:07:36,383 --> 00:07:55,243 OK, anyway you can get anything here, like what's operator, operator, it's not so easy to get operator

71 00:07:55,493 --> 00:08:00,560 you can get this way. operator... motions and operators.

72 00:08:00,810 --> 00:08:02,580 you can check this part

73 00:08:02,830 --> 00:08:14,562 this part for more information. so that's the general rule of vim

74 00:08:14,812 --> 00:08:23,153 uh... how to use vim in this normal mode. the general rule is one operator then followed with some motion

75 00:08:18,562 --> 00:08:27,820 command, motion commands can be multiplied by numbers

76 00:08:28,070 --> 00:08:33,904 three 'w' like two 'w'. it's like this, like this

77 00:08:34,154 --> 00:08:39,546 like, now I want to change three words. 'c' three 'w'

78 00:08:39,796 --> 00:08:47,000 you see, then we type something new. "hello", then press "Esc"

79 00:08:47,250 --> 00:08:51,946 then you see three words changed into one word, in this way

80 00:08:52,196 --> 00:08:59,585 anyway, still the same thing, change words, like this "hello", OK

81 00:08:59,835 --> 00:09:01,838 easy, uh?

82 00:09:02,088 --> 00:09:10,545 those general rule of vim, of course you can use those many many different ways, because there are

83 00:09:10,795 --> 00:09:19,508 still other more operators and other more motions, check help file and enjoy the power. so

84 00:09:19,758 --> 00:09:25,104 anyway, OK. let's call it today. my stomach still hurts.

85 00:09:25,354 --> 00:09:34,485 uh... but I've done something meaningful and I feel my life is meaningful. OK

86 00:09:34,735 --> 00:09:39,106 OK, stop talking all these nonsense. have a good day.

87 00:09:39,356 --> 00:09:42,856 talk to you later

happypeter commented 9 years ago

1 00:00:00,000 --> 00:00:02,647 hi, hi, peter again

2 00:00:02,897 --> 00:00:10,937 in our earlier talk we mentioned operators and motions

3 00:00:11,187 --> 00:00:20,503 and how can we use both of them to constitute, uh... construct a whole vim command

4 00:00:20,753 --> 00:00:23,963 are you still remembering general rules?

5 00:00:24,213 --> 00:00:27,051 uh... let's say "hello world", something like this

6 00:00:27,301 --> 00:00:34,366 you have, first type one operator, then a number, then motion

7 00:00:34,616 --> 00:00:40,472 it's something like this. like "dj", anything like this

8 00:00:40,722 --> 00:00:50,736 uh... we talk about that, but we didn't cover enough of those motions and operators

9 00:00:50,986 --> 00:00:59,234 of course not all of those operators, and all of them, uh... there are hundred of them

10 00:00:59,484 --> 00:01:05,666 maybe not hundred of them, but certainly lots of them

11 00:01:05,916 --> 00:01:08,545 we don't need to remember all of them, but there are still,

12 00:01:08,795 --> 00:01:13,956 maybe a few of them that are really really useful.

13 00:01:14,206 --> 00:01:19,552 so that I really need to talk about in our screencast

14 00:01:19,802 --> 00:01:25,449 just now, I just think about that how to do this screencast

15 00:01:25,699 --> 00:01:36,456 I certainly believe it will be really boring to just talk about operators and motions

16 00:01:36,706 --> 00:01:42,679 in a plain way, I just type one by one, it will be really boring

17 00:01:42,929 --> 00:01:48,484 like 'w', like 'jj' like 'j', something like this it will be boring

18 00:01:48,734 --> 00:02:02,694 so, but suddenly a good idea come to me, and I need to, I think I would rather to talk, give this screencast a topic

19 00:02:02,944 --> 00:02:09,080 it's something uh... stupid. uh... named big and small

20 00:02:09,330 --> 00:02:15,605 big and small, maybe you don't know what big and small means

21 00:02:15,855 --> 00:02:24,103 here, I want to say, just I will talk about 'O', I talk about 'o'

22 00:02:24,353 --> 00:02:27,377 it's lowercase 'o' and capital 'O'

23 00:02:27,627 --> 00:02:30,233 so we just call it small 'o' and big 'O'

24 00:02:30,483 --> 00:02:40,194 and, small 'y' and big 'Y', small 'p' and big 'P', small 'i' and big 'I'

25 00:02:40,444 --> 00:02:48,252 so, uh... I'm Chinese, in China, we always talk about lowercase as something small

26 00:02:48,502 --> 00:02:52,083 and the uppercase as something big

27 00:02:52,333 --> 00:02:56,565 uh... I am not sure the native speakers talk this way

28 00:02:56,815 --> 00:03:01,626 uh... anyway I don't care

29 00:03:01,876 --> 00:03:06,758 so, but anyway why they arep so important, let me show you

30 00:03:07,008 --> 00:03:13,144 so, first let's talk about how to go into insert mode from normal mode

31 00:03:13,394 --> 00:03:16,603 it's the most often used one is 'i'

32 00:03:16,853 --> 00:03:22,989 but, you know what is big 'I', it's like this, you type uh...

33 00:03:23,239 --> 00:03:28,120 small 'i' and you are in insert right before the cursor

34 00:03:28,370 --> 00:03:36,271 and if you type big 'I', then you start your insert at the beginning of the line

35 00:03:36,521 --> 00:03:38,384 this is really useful

36 00:03:38,634 --> 00:03:45,489 and another useful one is, you type 'a' and the small 'a'

37 00:03:45,739 --> 00:03:48,949 uh... you can insert right after the cursor position

38 00:03:49,199 --> 00:03:53,802 and if you want to start editing at the end of this line

39 00:03:54,052 --> 00:03:55,613 you just type big 'A'

40 00:03:55,623 --> 00:04:00,164 it's like this the small 'a' and big 'A'

41 00:04:00,414 --> 00:04:12,145 uh... OK, small 'a' and big 'A'. OK, now what small 'o' and big 'O' means?

42 00:04:12,395 --> 00:04:24,150 small 'o' means this, you open, you go from normal mode to insert mode, but you open a new line

43 00:04:24,400 --> 00:04:30,234 and this start editing. what big 'O' means? it's like this. you type big 'O' and

44 00:04:30,484 --> 00:04:35,319 you also go to insert mode but you start a new line above the cursor position

45 00:04:35,569 --> 00:04:47,579 so that's the difference. then uh... one common editing task is that you need to copy and paste

46 00:04:47,829 --> 00:04:53,547 uh... in vim you don't call it copy, you call it yank, "yank", yank

47 00:04:53,797 --> 00:05:04,483 uh... maybe you don't know what "yank" means, you can help, try help 'y', like this

48 00:05:04,733 --> 00:05:11,681 and also if you don't know any of those big and small bullshit

49 00:05:11,931 --> 00:05:17,138 you can just help, help 'p', like this

50 00:05:17,388 --> 00:05:19,530 and of course, you get a big 'P' here

51 00:05:19,780 --> 00:05:25,149 and you can also check, maybe help 'w'

52 00:05:25,399 --> 00:05:27,912 you also have small 'w' and big 'W'

53 00:05:28,162 --> 00:05:32,579 that's different words, big word and small word

54 00:05:32,829 --> 00:05:38,222 and they are different. you can check help file for more information

55 00:05:38,472 --> 00:05:49,321 and anything you know vim help system is really powerful, you generally can find anything in the help system

56 00:05:49,571 --> 00:06:00,049 but we are not going show you all of them in our screencast... time is limited. so

57 00:06:00,299 --> 00:06:10,126 let's continue. maybe I think, I need talk about yank a paste. OK, how to yank a line

58 00:06:10,238 --> 00:06:18,067 it's like this. 'y', OK, now this line is in one of those special buffer

59 00:06:18,317 --> 00:06:26,357 then I can type, put. it's not paste, it's like paste, but it's not paste

60 00:06:26,607 --> 00:06:34,948 we call it put, then it's small 'p'. I'm sorry

61 00:06:35,198 --> 00:06:39,662 you find to yank the whole line, you need to type 'yy'

62 00:06:39,912 --> 00:06:43,377 and if you want to put, you type 'p'

63 00:06:43,627 --> 00:06:52,711 and let's try again, you have, you have 'yy' here, now 'p'

64 00:06:52,961 --> 00:06:57,263 you type 'p', then you put something below the current line

65 00:06:57,513 --> 00:07:03,369 and, but if you type big 'P', you put something above the current line

66 00:07:03,619 --> 00:07:05,622 so that's the difference

67 00:07:05,872 --> 00:07:10,498 and yeah that's big and small

68 00:07:10,748 --> 00:07:17,905 cut and paste, big and small, and anything

69 00:07:18,155 --> 00:07:26,404 OK, that's my stupid idea of giving such name big and small

70 00:07:26,654 --> 00:07:31,582 of this screencast to make things maybe a little more funny

71 00:07:31,832 --> 00:07:34,577 uh... maybe it's not funny at all

72 00:07:34,827 --> 00:07:41,311 but, OK that's all i want to talk about. so, enjoy, bye