Missing semester
Missing semester
MIT Missing Semester —— CH01 Shell
MIT Missing Semester —— CH02 Vim
MIT Missing Semester —— CH03 Data Wrangling
MIT Missing Semester —— CH04 Command-line Environment
…
以下为本人参加学习 MIT-Missing-Semester 课程的笔记记录,若有疏漏错误,望友好指正!
课程 youtube视频
课程中文字幕视频:
特别感谢由 CS自学指南 提供的资源导航网站与各类解答,非常感谢!
Vim
fundamental
based on Modal
Modal
- Normal: for moving around a file and making edits (browse and edit)
i— Insert
R / shift + r— replace
v—visual
shift + v—visual line
ctrl + v— visual block
esc— Normal
:— command line - Insert: for inserting text
- replace: for replacing text
- selector: for selecting blocks of text
visual, visual line, visual block - command line: for running a command
Basics
cmd
:qquit (close window):wsave (“write”):wqsave and quit:e {name of file}open file for editing:lsshow open buffers:help {topic}open help:help :wopens help for the:wcommand:help wopens help for thewmovement
Movement — Normal mode
-
Basic movement:
hjkl(left, down, up, right) -
Words:
w(next word),b(beginning of word),e(end of word) -
Lines:
0(beginning of line),^(first non-blank character),$(end of line) -
Screen:
H(top of screen),M(middle of screen),L(bottom of screen) -
Scroll:
Ctrl-u(up),Ctrl-d(down) -
File:
gg(beginning of file),G(end of file) -
Line numbers:
:{number}<CR>or{number}G(line {number}) -
Misc:
%(corresponding item) -
Find:
f{character}: find {character} forwardt{character}: to {character} forwardF{character}: find {character} backwardT{character}: to {character} backward,/;for navigating matches
-
Search:
/{regex},n/Nfor navigating matches
Selection — Visual mode
- Visual:
v - Visual Line:
V - Visual Block:
Ctrl-v
Can use movement keys to make selection.
Edits
Everything that you used to do with the mouse, you now do with the keyboard using editing commands that compose with movement commands. Here’s where Vim’s interface starts to look like a programming language. Vim’s editing commands are also called “verbs”, because verbs act on nouns.
i: enter Insert mode- but for manipulating/deleting text, want to use something more than backspace
o/Oinsert line below / above
open a new line and enter the Insert moded{motion}: delete {motion}dwis delete word
d$is delete to end of line
d0is delete to beginning of line
c{motion}: change {motion}cwis change word- like
d{motion}followed byi
xdelete character (=dl)ssubstitute character (=cl)- Visual mode + manipulation
- select text,
dto delete it orcto change it
- select text,
uto undo,<C-r>to redoyto copy / “yank” (some other commands likedalso copy)pto paste- Lots more to learn: e.g.
~flips the case of a character
Counts
You can combine nouns and verbs with a count, which will perform a given action a number of times.
-
3wmove 3 words forward -
5jmove 5 lines down -
7dwdelete 7 words
Modifiers
You can use modifiers to change the meaning of a noun. Some modifiers are i, which means “inner” or “inside”, and a, which means “around”.
ci(change the contents inside the current pair of parenthesesci[change the contents inside the current pair of square bracketsda'delete a single-quoted string, including the surrounding single quotes
本篇笔记后半部分摘自课程网站本节课讲义
961

被折叠的 条评论
为什么被折叠?



