MIT Missing Semester —— CH02 Vim

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 课程的笔记记录,若有疏漏错误,望友好指正!

课程网站链接 Eng
课程网站链接 CH

课程 youtube视频

课程中文字幕视频:

特别感谢由 CS自学指南 提供的资源导航网站与各类解答,非常感谢!

Vim

fundamental

based on Modal

Modal

  1. 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
  2. Insert: for inserting text
  3. replace: for replacing text
  4. selector: for selecting blocks of text
    visual, visual line, visual block
  5. command line: for running a command

Basics

cmd
  1. :q quit (close window)
  2. :w save (“write”)
  3. :wq save and quit
  4. :e {name of file} open file for editing
  5. :ls show open buffers
  6. :help {topic} open help
    • :help :w opens help for the :w command
    • :help w opens help for the w movement
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} forward

    t{character}: to {character} forward

    F{character}: find {character} backward

    T{character}: to {character} backward

    • , / ; for navigating matches
  • Search: /{regex}, n / N for 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 / O insert line below / above
    open a new line and enter the Insert mode
  • d{motion}: delete {motion}
    • dw is delete word
      d$ is delete to end of line
      d0 is delete to beginning of line
  • c{motion}: change {motion}
    • cw is change word
    • like d{motion} followed by i
  • x delete character (= dl)
  • s substitute character (= cl)
  • Visual mode + manipulation
    • select text, d to delete it or c to change it
  • u to undo, <C-r> to redo
  • y to copy / “yank” (some other commands like d also copy)
  • p to 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.

  • 3w move 3 words forward

  • 5j move 5 lines down

  • 7dw delete 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 parentheses
  • ci[ change the contents inside the current pair of square brackets
  • da' delete a single-quoted string, including the surrounding single quotes

本篇笔记后半部分摘自课程网站本节课讲义

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值