Lecture 3: Editors (vim) (2020)

Missing Semester
1 Feb 202048:26

Summary

TLDR本次讲座深入探讨了文本编辑器vim的强大功能和高效编程理念。通过vim的多模式操作,讲解了如何在编程中快速导航和编辑文本。强调了vim的可编程性和通过.vimrc文件进行个性化配置的能力,以及通过插件扩展功能的方法。此外,还介绍了vim模式在其他程序中的应用,如Python REPL和终端,以及如何通过练习和探索配置来精通vim。

Takeaways

  • 📝 Vim 是一个程序员文本编辑器,与编写英语散文的文本编辑器有所不同,因为它专为编程设计。
  • 🔍 Vim 拥有多种操作模式,如普通模式(Normal Mode)、插入模式(Insert Mode)和命令行模式(Command Line Mode)等。
  • ⏫ 在 Vim 中,可以使用 hjkl 键进行光标移动,这比使用箭头键更高效。
  • 🔑 Vim 的强大之处在于其模态编辑,可以将不同的键组合在一起,类似于编程语言中的函数和命令组合。
  • 📖 Vim 支持通过键盘快捷键执行命令,如保存文件(:w)、退出编辑器(:q)等,而无需使用鼠标。
  • 🔄 Vim 中的复制(y)、粘贴(p)和删除(d)命令可以通过结合移动命令来操作文本。
  • 🔢 在 Vim 中,可以通过数字前缀(如 4j)来重复执行移动或编辑命令多次。
  • 📌 Vim 允许用户自定义配置文件(vimrc),以便根据个人喜好调整编辑器的行为和外观。
  • 🔧 Vim 可以通过插件扩展功能,如模糊文件查找、撤销历史可视化和文件资源管理器等。
  • 📈 Vim 的模式也可以在其他程序中使用,如 Python REPL、终端和 Jupyter Notebook 等,提高在这些工具中的编辑效率。
  • 🚀 学习 Vim 可能需要一定的时间和练习,但一旦掌握,可以极大提高编程和文本编辑的效率。

Q & A

  • 文本编辑器对于程序员的重要性是什么?

    -文本编辑器对于程序员非常重要,因为程序员花费大量时间编辑文本和程序代码。如果能够通过使用文本编辑器提高编辑效率,那么在本科学习或职业生涯中可以节省数百小时的时间。

  • 为什么程序员在选择文本编辑器时应该坚持使用一种特定的工具?

    -坚持使用一种特定的文本编辑器可以使程序员更加熟练掌握该工具,从而提高编程效率。尽管一开始可能会因为学习新工具而降低速度,但在大约20小时的编程实践后,程序员将恢复到原来的编程速度,并随着对工具的深入理解而不断提高效率。

  • Vim的 modal editor(模态编辑器)概念是什么?

    -Vim是一个模态编辑器,意味着它有多个操作模式。这些模式包括普通模式(normal mode)、插入模式(insert mode)、替换模式(replace mode)等。在普通模式下,按键用于导航和编辑操作,而在插入模式下,按键则直接输入文本。这种设计允许程序员根据任务的不同选择合适的模式,提高编辑效率。

  • Vim中的normal mode(普通模式)和insert mode(插入模式)有什么不同?

    -在Vim中,普通模式主要用于导航和编辑操作,如移动光标、删除字符、复制和粘贴文本等。插入模式则是用于输入文本,当进入插入模式时,按键会直接将字符输入到文本中。程序员可以根据当前任务的需要在这两种模式之间切换。

  • 如何在Vim中打开和保存文件?

    -在Vim中,可以通过命令行模式来打开和保存文件。要打开文件,只需在命令行中输入`vim`后跟文件名。要保存文件,可以在普通模式下按`:`进入命令行模式,然后输入`w`保存更改。如果想要退出Vim,可以输入`:q`来关闭编辑器,或者`:q!`来放弃所有更改并退出。

Outlines

00:00

📝 介绍与文本编辑器的重要性

本段落介绍了本次讲座的主题——文本编辑器,强调了作为程序员,我们花费大量时间编辑文本和程序,因此提高编辑效率能节省大量时间。讲师分享了自己对文本编辑器的热爱,并指出不同编程场景需要不同的编辑工具,例如 Vim、Emacs、VS Code 和 Sublime 等。此外,讲师还强调了学习文本编辑器的重要性,并介绍了今天讲座的主要内容,包括教程和练习,以及如何通过坚持使用和探索来掌握这些工具。

05:01

🌟 Vim编辑器及其多模式特性

这一部分详细讲解了Vim编辑器及其多模式特性。Vim是一个模式编辑器,具有多种操作模式,如普通模式、插入模式、替换模式等。每种模式都有其特定的用途和按键组合,例如在普通模式下,按键用于导航和编辑,而在插入模式下,按键则直接输入文本。讲师还提到了Vim的一些高级特性,如可视化模式和命令行模式,并解释了如何通过按键组合在不同模式间切换。

10:02

📖 Vim的基本操作和命令

在这一部分中,讲师介绍了Vim的一些基本操作和命令,包括如何打开文件、保存更改以及退出Vim。详细讲解了命令行模式下的命令输入方法,例如使用':w'保存文件,':q'退出Vim等。此外,还介绍了如何使用帮助系统来获取关于Vim命令的信息,以及如何通过键盘快捷键执行常用操作,而不必使用鼠标,从而提高编辑效率。

15:04

🔍 Vim的缓冲区、窗口和标签页模型

本段落深入探讨了Vim的缓冲区、窗口和标签页的概念及其工作方式。Vim维护一组打开的缓冲区,代表打开的文件,用户可以在多个标签页和窗口中查看这些缓冲区。每个标签页可以包含多个窗口,而每个窗口对应一个缓冲区。特别地,一个缓冲区可以在多个窗口中打开,这使得同时查看和编辑同一个文件的不同部分成为可能。此外,还讨论了关闭窗口和退出Vim的命令,以及如何使用':qa'命令一次性关闭所有窗口并退出Vim。

20:05

🛠 Vim的普通模式和编辑效率

这一部分重点介绍了Vim的普通模式,解释了为什么它是Vim最有趣的特性之一。普通模式允许用户通过编程方式与Vim接口进行交互,不同的按键组合有不同的效果,并且可以组合使用,就像编程语言一样。通过使用普通模式,用户可以快速移动光标、编辑文本和执行复杂的编辑任务。讲师还强调了通过普通模式进行编辑可以大大提高编辑速度,使得编辑文件的速度接近于思考的速度。

25:05

➡️ Vim的移动命令和编辑命令

在这一部分中,讲师详细介绍了Vim的移动命令和编辑命令。移动命令包括使用hjkl键进行光标移动、使用W和B键移动到单词的开头和结尾、使用0和$键移动到行的开头和结尾等。编辑命令则包括i命令进入插入模式、o和O命令打开新行、D命令删除文本、u命令撤销更改等。讲师还解释了如何使用可视模式来选择和操作文本块,以及如何使用修饰键如'a'和'i'来改变移动命令的行为。

30:06

🔄 Vim的复制粘贴、计数和修饰符

本段落讲解了Vim中的复制粘贴操作,包括y命令用于复制文本、p命令用于粘贴文本,以及如何结合移动命令来选择要复制的文本。计数功能允许用户通过数字前缀来重复命令多次。修饰符如'a'和'i'可以改变移动命令的行为,'a'代表around(环绕),'i'代表inside(内部)。讲师还提到了如何使用这些功能来提高编辑效率,并展示了如何通过组合不同的命令来执行复杂的编辑任务。

35:07

📚 Vim的可编程性和在其他程序中的应用

这一部分讨论了Vim的可编程性,包括如何通过修改vimrc文件来配置Vim,以及如何使用插件来扩展Vim的功能。讲师提到了Vim的配置文件vimrc,以及如何通过这个文件来开启语法高亮和行号等特性。此外,还介绍了Vim的插件系统,可以通过安装插件来增加如模糊文件查找、撤销历史可视化等功能。最后,讲师提到了Vim模式在其他程序中的应用,如Python REPL、终端和Jupyter Notebook等,可以通过启用Vim模式来提高这些工具的编辑效率。

Mindmap

Keywords

💡文本编辑器

文本编辑器是程序员编写和修改代码的主要工具。在视频中,特别强调了文本编辑器与普通文本处理软件的不同,因为编程时需要频繁阅读和编辑代码,而不仅仅是像写文章那样连续输入。

💡Vim

Vim 是一种在命令行界面中运行的高效文本编辑器,它通过模式编辑和键盘快捷操作来提高编程效率。Vim 拥有多种模式,如普通模式、插入模式和命令模式等,每种模式下按键的功能都不相同。

💡模式编辑

模式编辑是 Vim 编辑器的核心特性之一,指的是 Vim 根据当前所处的模式(如普通模式、插入模式)改变按键的功能。这种设计使得用户可以通过键盘快捷键高效地执行编辑任务,而不需要使用鼠标。

💡键盘快捷键

键盘快捷键是指通过组合键盘上的键来快速执行命令或操作。在 Vim 中,键盘快捷键被广泛应用于各种编辑任务中,从而提高编辑效率和速度。

💡效率

效率是指完成任务所需的时间和精力的多少。在视频中,提高编辑效率是通过学习和使用 Vim 这样的文本编辑器来实现的,它能通过减少不必要的鼠标操作和提供强大的键盘快捷操作来节省时间。

💡插入模式

插入模式是 Vim 编辑器中的一种模式,用户可以在这种模式下像在普通文本编辑器中一样输入文本。从普通模式进入插入模式后,按下的键将会直接插入到文本中,而不是执行其他编辑命令。

💡命令模式

命令模式是 Vim 编辑器提供的一种模式,用户可以在此模式下执行编辑命令,如保存文件、退出编辑器等。进入命令模式是通过按下 ':' 键实现的,然后用户可以输入相应的命令来执行操作。

💡光标导航

光标导航是指在文本编辑器中移动光标位置的操作。在 Vim 中,光标导航主要通过键盘快捷键完成,如使用 'hjkl' 键在普通模式下上下左右移动光标。

💡文本操作

文本操作包括在文本编辑器中对文本进行的各种编辑任务,如插入、删除、修改和复制粘贴等。Vim 提供了丰富的文本操作命令,可以通过键盘快捷键高效地完成这些任务。

💡撤销和重做

撤销和重做是文本编辑中的两个基本功能,允许用户取消之前的操作或重新执行已经撤销的操作。在 Vim 中,可以通过 'u' 命令撤销更改,通过 'Ctrl + R' 命令重做更改。

Highlights

文本编辑器对于程序员来说非常重要,因为编程工作很大一部分时间都在编辑文本。

不同于编写英语散文,编程时你会花很多时间阅读已编写的代码,频繁地在代码中导航和进行小的修改。

Vim 和 Emacs 等文本编辑器与 Microsoft Word 这类编辑英语散文的程序不同,它们专门为编程设计。

学习文本编辑器的关键是开始使用教程,然后坚持使用该编辑器完成所有编辑任务。

Vim 是一个功能强大的编辑器,虽然最初可能会降低你的编程速度,但坚持下去,你会逐渐提高效率。

Vim 是一个模态编辑器,它有多个操作模式,不同模式下按键的功能不同。

Vim 的正常模式(Normal Mode)用于导航和读取代码,插入模式(Insert Mode)用于输入文本。

Vim 有很多其他模式,例如替换模式(Replace Mode)、视觉模式(Visual Mode)和命令行模式(Command Line Mode)。

Vim 的设计理念是尽可能通过键盘操作,避免使用鼠标,以提高编程效率。

Vim 通过命令行模式可以执行各种命令,如保存文件、退出编辑器等。

Vim 的帮助系统非常强大,你可以通过 :help 命令获取关于特定命令或按键的帮助信息。

Vim 的缓冲区(Buffers)、窗口(Windows)和标签页(Tabs)的概念与其他编辑器不同,一个缓冲区可以对应多个窗口。

Vim 的正常模式允许你使用键盘快捷键进行快速编辑和导航,这使得你可以几乎以思考的速度编辑文件。

Vim 的界面本身就是一种编程语言,不同的按键组合有不同的效果,可以组合它们以执行复杂的编辑任务。

Vim 支持通过键盘快捷键进行复制和粘贴操作,这比使用鼠标更高效。

Vim 允许用户通过修改配置文件 vimrc 来定制编辑器的行为,以符合个人喜好。

Vim 可以通过插件扩展功能,这些插件可以提供模糊文件查找、撤销历史可视化、文件浏览器等增强功能。

Vim 模式也可以在其他程序中启用,如 Python REPL、终端、Jupyter Notebook 等,这使得你可以在不同环境中使用相同的编辑技巧。

Transcripts

00:00

Okay, cool. So, welcome to the third

00:03

lecture of the missing semester of your

00:05

si a second today we're going to be

00:07

talking about text editors this is a

00:09

topic that I really like I think it's

00:11

one of the most valuable topics that

00:13

we're teaching in this class because as

00:14

programmers you spend so much of your

00:17

time editing text editing programs that

00:19

if you invest time into making yourself

00:21

more efficient at doing this you'll save

00:23

a ton of time probably hundreds of hours

00:25

over the course of your undergrad or

00:27

over the course of your career so text

00:31

editors are a little bit different than

00:33

other programs you might use to edit say

00:36

things like English prose because

00:38

programming is different than writing

00:39

English prose when you're programming

00:41

you spend a lot of time reading what

00:44

you've written you spend a lot of time

00:45

navigating around a buffer and you spend

00:47

a lot of time making little edits to

00:49

code all over the place rather than just

00:51

writing in a long stream like you do

00:52

when you're writing an essay or

00:53

something and so it makes sense that

00:55

there different programs for these

00:56

different purposes right so yeah things

00:57

like Microsoft Word for writing essays

00:59

and things like vim and Emacs and vs

01:01

code and sublime for writing code so the

01:05

way you learn a text editor and become

01:07

really good at it is you start with a

01:09

tutorial and so that's basically going

01:11

to be the function of today's lecture

01:12

plus the exercises we've given you and

01:15

then after the tutorial you need to

01:17

stick with the editor for all your

01:19

editing tasks and when you're learning a

01:22

sophisticated tool so today we're going

01:24

to teach you vim which is one powerful

01:25

editor that a lot of programmers use

01:26

when you're learning such a

01:28

sophisticated tool it may be the case

01:30

that initially switching to this tool

01:32

slows you down a little bit when you're

01:33

programming but stick with it because

01:35

I'd say that in about 20 hours of

01:38

programming using a new editor you'll be

01:41

back to the same speed at which you

01:42

programmed using your old tool and then

01:44

after that the benefits will start and

01:46

you'll get faster and faster as you

01:47

learn more with these sophisticated

01:50

programs like them it takes not way too

01:53

long to learn the basics but a lifetime

01:55

to master and so throughout the time

01:58

you're using this tool make sure you

01:59

look things up as you go if you ever get

02:01

to a point where you're like oh this is

02:03

a really inefficient way of doing things

02:04

is there a better way the answer is

02:06

almost always yes because these text

02:09

editors were written by programmers for

02:11

programmers and so of course like the

02:13

peep

02:13

I wrote these tolls ran into the same

02:15

kinds of issues and fixed them so that

02:17

you don't need to deal with these

02:18

anymore and so yeah as you're learning

02:19

make sure you look things up as you go

02:21

either use Google or feel free to send

02:23

us emails if you have questions or come

02:25

to office hours and we'll help you

02:27

figure out how to do things really fast

02:29

so as far as which editor to learn in

02:32

previous iterations of this class we

02:34

actually avoided teaching a specific

02:35

editor because we didn't want to enforce

02:36

our opinions on you guys but we actually

02:39

think that it's really useful to teach

02:40

you how to use one particular tool and

02:42

use it well and so people have really

02:44

strong opinions about editor so you can

02:46

see the course notes for more links on

02:48

this topic looking at which editors have

02:52

been popular over the years Stack

02:54

Overflow I'm sure you've all heard of

02:56

that does a survey every year asking

02:59

developers various questions and one

03:00

thing to ask is which TextEdit Derk do

03:02

you use and it seems to be that

03:03

currently the most popular kind of

03:05

graphical editor is vs code and the most

03:07

popular editor that is based within a

03:10

command line interface is vim and so

03:12

we're going to be teaching you vim and

03:13

there a couple reasons for this one is

03:16

that all the instructors so me John and

03:17

Jose use vim as our primary editor and

03:19

we've been doing this for many years and

03:21

we've been very happy with it

03:23

and we think that there are a lot of

03:25

interesting ideas behind them so even if

03:28

you don't end up using this particular

03:30

tool in the long term I think it's

03:32

valuable to learn these ideas and also a

03:35

lot of tools have actually been really

03:37

excited about the ideas in vim and so

03:39

they support a vim emulation mode for

03:42

example vs code what's apparently the

03:44

most popular editor in use today

03:45

supports vim bindings and this vim

03:48

emulation mode as of now has like 1.4

03:50

million downloads and as you'll see over

03:53

the course of this lecture a lot of

03:56

different tools like including your

03:57

shell including things like the Python

03:59

repple and like Jupiter notebook and all

04:01

sorts of other things even your web

04:03

browser can support of emulation mode

04:04

and so yeah we're going to be teaching

04:06

you this really neat tool today and in

04:10

this lecture we can't really cover all

04:12

of them right it's a very powerful tool

04:14

but our goal is to teach you and the

04:17

core philosophy of them like the really

04:18

neat ideas behind it and then in

04:20

addition to that some of the basics like

04:22

how do you open a file close a file

04:23

navigate around a file make edits and

04:25

things like that and

04:27

you may not remember every single little

04:28

detail from this lecture because we're

04:29

gonna go pretty fast through some of the

04:31

material but it's all in the lecture

04:32

notes and then the exercises actually

04:34

give you links to some tutorials and

04:36

things so I highly recommend that you

04:37

actually go through all the exercises at

04:40

least the non advanced exercises any

04:43

questions so far great okay so one of

04:49

the really cool ideas behind them is

04:51

that vim is a modal editor what does

04:54

this mean modal comes from the word mode

04:56

and this means that vim has multiple

04:58

operating modes and this is kind of

05:00

developed from the idea that when you're

05:02

programming there often times where

05:04

you're doing different types of things

05:05

like sometimes you're reading code

05:07

sometimes you're making small edits to

05:09

code like you're finding a particular

05:10

point like changing a little thing

05:12

somewhere sometimes you're just writing

05:15

a lot of code in one go like suppose

05:16

you're just writing a function from

05:17

scratch and so there's different

05:19

operating modes for doing these

05:20

different types of things and so I'm

05:24

actually want to write this down on the

05:25

blackboard so I'll have a useful thing

05:26

to refer to later so when you start vim

05:28

up it starts up in what's called normal

05:33

mode and in this mode all the different

05:35

key combinations behave in one way and

05:37

then there are different key

05:38

combinations that switch you between

05:40

normal mode and other modes which change

05:42

the meaning of different keys so for the

05:45

most part you'll be spending most of

05:47

your time in vim in normal mode or what

05:49

is called insert mode and to go to

05:55

insert mode you press the key I for

05:57

normal mode and to go from insert mode

05:59

back to normal mode you press the Escape

06:01

key a little note on notation because

06:06

we'll need this later in the notation

06:09

I'm going to be using in this lecture

06:11

and what's also in the lecture notes and

06:12

what vim uses to give you feedback they

06:15

have a couple different ways of talking

06:16

about different keys so when they're

06:17

talking about bare keys like just the

06:19

eye key on your keyboard they'll just

06:20

say eye but for a different key

06:22

combinations like when you press control

06:24

and something like say control V it's

06:27

notated in one of like approximately

06:29

three ways one way that can be notated

06:32

is a caret and then the control

06:34

character so this is control V another

06:37

way this might be written I think we've

06:39

written it this way in

06:40

lecture notes as control-v this is

06:42

probably the one you're more used to

06:43

seeing and then in some parts of them

06:46

this is written as angle brackets C - V

06:48

close angle bracket so just a little bit

06:51

of notation that will be useful later

06:54

so yeah vim has a couple different modes

06:56

where normal mode is designed for

06:59

navigating around a file reading things

07:01

going from file to file things like that

07:03

and then insert mode is where you type

07:05

in text so most keys that you press here

07:08

will just go into your text buffer where

07:10

as keys that you press here are not

07:12

being put into the buffer and instead

07:13

are used for things like navigation or

07:15

making edits and actually the picture is

07:20

a little bit more complicated than this

07:21

there are a whole bunch of other modes

07:23

and I'm just gonna write them down here

07:24

because we'll have them here to refer to

07:25

later and so if it also has a replace

07:29

mode for rather than inserting text and

07:33

kind of pushing what's ahead of it

07:34

forward it will overwrite text and then

07:36

it has a bunch of different modes for

07:37

selection so it has a mode called visual

07:44

mode and then it has visual line and

07:48

visual block this one is enter via the R

07:53

key this was entered via the V key this

07:57

one is entered via shift B and this one

08:01

is entered via control V and then

08:05

there's the command line mode which is

08:13

entered via the colon key

08:19

okay so now that we have that on the

08:21

board to refer to later we can actually

08:31

try some of this out all right so one

08:35

thing we noticed looking at that picture

08:36

is that to go from normal mode to any of

08:38

the other modes we press some key but to

08:40

go from any of the other modes back to

08:41

normal mode where we spend a lot of our

08:43

time we use the Escape key on our

08:45

keyboard so for this reason since you

08:48

under pressing the Escape key a lot when

08:49

using vim a lot of programmers rebind

08:51

one of the keys on their keyboard to be

08:53

escape because it's really inconvenient

08:55

to reach up with your left pinkie to

08:56

press that tiny little Escape key in the

08:58

corner of your keyboard and so a lot of

08:59

people use the caps lock key instead so

09:01

it's right there in the home row and we

09:04

have some links in the lecture notes for

09:06

how you can do this key rebinding okay

09:14

so now that we've talked about kind of

09:15

one of the core ideas of vim the idea of

09:17

modal editing we can talk about some of

09:19

the basics like how do you open up this

09:20

text editor how do you open file save

09:23

files and things like that and so this

09:25

is a command line based program although

09:28

there are some graphical variants and

09:29

the way you start this program is by

09:31

running vim one thing you might notice

09:34

is that in the bottom left corner of my

09:35

screen they actually saw what I just

09:37

typed this will be useful later in this

09:40

lecture where I'm actually typing in

09:41

commands for vim and I'll be saying what

09:44

I'm typing but you'll also see it on the

09:45

screen so if I press ctrl C see it says

09:47

ctrl C over there is that text big

09:50

enough for everybody to read great okay

09:55

so the way we open vim is just by

09:57

running the program vim on our command

09:59

line and this comes pre-installed on

10:02

most systems and if you don't have it

10:03

you can install it using your package

10:05

manager vim can also take an argument if

10:07

we want to use it to edit a particular

10:08

file instead of just opening up the

10:10

program then later opening a file so for

10:12

example I have a file in this directory

10:15

this is actually the lecture notes for

10:17

this lecture so I can do vim editors MD

10:19

and press ENTER and then boom them is

10:21

started and then in this lecture I'm not

10:25

running vim in the completely Exton I've

10:29

configured a couple of things that

10:32

behave a little bit nicer by defaults

10:34

little things like having line numbers

10:36

on the left or having some more status

10:38

information on the bottom and if you

10:40

want to start with this default

10:41

configuration we have a link to this in

10:42

the lecture notes so you can get a

10:43

slightly more sane config by default. So,

10:49

once you've opened Vim, what do you do?

10:51

Well, as I said earlier, Vim starts in

10:53

normal mode, so if I just start typing

10:54

letters like, say, type X it didn't insert

10:57

X into the buffer. You can see the cursor

10:59

up in the top left: it actually deleted

11:01

one of the characters. That's because I'm

11:03

in normal mode, not insert mode. So insert

11:07

mode is basically what you're used to with

11:08

all the other text editors you've used

11:09

in the past, where there's a cursor

11:10

somewhere, you press the character, and it

11:12

just goes into your buffer. I'm instead

11:15

in vim you start a normal mode and you

11:18

can press I to go into insert mode so

11:19

see I've pressed I and then in the

11:21

bottom left notice that it says - -

11:23

insert the bottom left always tells you

11:26

what mode you're in unless this normal

11:27

mode in which case it's blank and now

11:29

that I'm an insert mode if I press the X

11:31

character for example see it just gets

11:33

inserted into my text buffer and I can

11:35

backspace over at type other stuff and

11:37

now my text editor kind of behaves like

11:39

you'd expect any other program to behave

11:41

so from this point how to go back to

11:43

normal mode if I want to stop inserting

11:45

characters. Yes, exactly. I press escape.

11:48

And, that's the symbol my keystroke

11:51

visualizer uses for escape, so

11:53

just be aware of that. And then, Vim has

11:58

this idea, that using the mouse is

12:01

inefficient, like your hands are on the

12:02

keyboard, moving your hand over to the

12:04

mouse takes a lot of time, right, like you

12:06

don't want to waste those couple of

12:08

milliseconds while you're programming,

12:09

like in the middle of things. So, instead,

12:11

all Vim functionality can be accessed

12:13

just through the keyboard. And, it's all

12:15

sorts of things you might be used to

12:16

doing like opening files by going, like,

12:19

file open, or file save, or things like

12:21

that, or instead access through the

12:23

keyboard. And, how is that done? That's

12:25

done through one of the other Vim modes

12:27

that are on the board over there. In

12:28

particular, through command line mode. So,

12:31

if you're in normal mode, and you press

12:33

the ":" key, you'll notice that the

12:36

cursor - I guess my visualizer is covering

12:39

the thing right now but it's gone - the

12:41

cursor jumps to the bottom - the bottom

12:43

left - and it shows that ":" I just typed.

12:46

Now, I can type in a command. So, you can

12:48

think of this almost like the command

12:50

shell that we've talked been talking

12:51

about over the last few days, except this

12:53

is Vim's

12:54

command shell, so you give Vim commands

12:55

here, instead of shell commands. And

12:57

there are a bunch of built-in commands

12:59

that do all the things that you're used

13:00

to. Like, for example, one command that you

13:02

might want to know is how to quit this

13:04

editor. You might notice that if you're in

13:05

normal mode, I can press "Escape" to go

13:07

back from command line mode to normal

13:08

mode, and I press "control C", unlike what

13:11

happens to a lot of programs, this doesn't

13:13

quit Vim. So, how do I quit Vim? I can

13:16

press ":", and then go into command

13:18

line mode, and then I can type in the

13:19

command "quit". "Q-U-I-T". You'll see that I

13:23

- maybe I should move this over to the

13:24

middle or something - see, it says ":quit"

13:28

and I press ENTER, and it quits Vim. I can

13:31

open Vim up again. There's actually a

13:32

short form for this command, just ":q", and

13:35

that'll do the same thing. And, there are a

13:38

bunch of other useful commands like this.

13:40

So, some other handy ones to know are

13:42

how do you save a file? So, suppose I make

13:45

some edits here, like "hello world".

13:47

So, I pressed "i" to go into insert mode - or

13:51

let me redo that - I press "i" to go into

13:53

insert mode. Right now, I can use the down

13:55

arrow to... I think I've slightly I

14:02

should fix that. Can you fix the config,

14:03

actually, John? Never mind that.

14:07

Okay, so, suppose I go down to this line,

14:11

and I press "i" to go into insert mode, and

14:14

type in some text, and then press "escape"

14:17

to go back to normal mode. Now, how do I

14:18

actually save this file? Well, there's

14:20

another command for that. So, ":" to go

14:22

into command mode, and then I can type "W"...

14:25

...and press "Enter". "W" stands for write. And,

14:30

it says in the bottom "editors.md"

14:33

whatever blah blah written. And, so, this

14:35

means it saved the file and so now if I

14:37

":q" to quit and open the same file,

14:40

again, you'll see that the changes have

14:42

been persisted. There are a couple other

14:46

there's... So, there's a ton of different

14:49

Vim commands that are useful for

14:50

different reasons. But, I'll just explain

14:53

a couple more to you now. One command

14:56

that's really useful is help. ":help"

14:59

And you can do ":help", and then type in a

15:01

particular key, or a particular command,