The missing semester 3习题

编辑器(vim)


1.完成 vimtutor。 备注:它在一个 80x24(80 列,24 行) 终端窗口看起来效果最好。

使用 vimtutor命令运行即可
这个教程中包含了大部分的常用操作,完成时间大约为1h+。这些命令需要长时间练习才能熟练!

2.下载我们提供的 vimrc,然后把它保存到 ~/.vimrc。 通读这个注释详细的文件 (用 Vim!), 然后观察 Vim 在这个新的设置下看起来和使用起来有哪些细微的区别。
.vimrc内容如下

"vimrc中双引号开头的语句将被视为注释
" Comments in Vimscript start with a `"`.


" If you open this file in Vim, it'll be syntax highlighted for you.
"如果在vim中打开此文件,这将会为你显示语法高亮
" Vim is based on Vi. Setting `nocompatible` switches from the default
" Vi-compatibility mode and enables useful Vim functionality. This
" configuration option turns out not to be necessary for the file named
" '~/.vimrc', because Vim automatically enters nocompatible mode if that file
" is present. But we're including it here just in case this config file is
" loaded some other way (e.g. saved as `foo`, and then Vim started with
" `vim -u foo`).
"vim基于vi,设置'nocompatible'来切换默认的"Vi-compatibility"模式并启用一些
"有用的vim功能。这些选项对于"~/.vimrc"文件来说是不必要的,因为Vim在文件存在的
"情况下自动的进入非兼容模式。但在这我们把它包括在这里,以免配置文件以其他方式加
载(例如保存为“foo”,然后Vim以' vim -u foo ')。
set nocompatible

" Turn on syntax highlighting.
"打开代码高亮
syntax on

" Disable the default Vim startup message.
"关闭vim的默认启动信息
set shortmess+=I

" Show line numbers.
"展示行号
set number

" This enables relative line numbering mode. With both number and
" relativenumber enabled, the current line shows the true line number, while
" all other lines (above and below) are numbered relative to the current line.
" This is useful because you can tell, at a glance, what count is needed to
" jump up or down to a particular line, by {count}k to go up or {count}j to go
" down.
set relativenumber

" Always show the status line at the bottom, even if you only have one window open.
"即使是在你仅打开一个窗口的情况下会令状态栏一直显示在底部。
set laststatus=2

" The backspace key has slightly unintuitive behavior by default. For example,
" by default, you can't backspace before the insertion point set with 'i'.
" This configuration makes backspace behave more reasonably, in that you can
" backspace over anything.
set backspace=indent,eol,start

" By default, Vim doesn't let you hide a buffer (i.e. have a buffer that isn't
" shown in any window) that has unsaved changes. This is to prevent you from "
" forgetting about unsaved changes and then quitting e.g. via `:qa!`. We find
" hidden buffers helpful enough to disable this protection. See `:help hidden`
" for more information on this.
set hidden

" This setting makes search case-insensitive when all characters in the string
" being searched are lowercase. However, the search becomes case-sensitive if
" it contains any capital letters. This makes searching more convenient.
set ignorecase
set smartcase

" Enable searching as you type, rather than waiting till you press enter.
set incsearch

" Unbind some useless/annoying default key bindings.
nmap Q <Nop> " 'Q' in normal mode enters Ex mode. You almost never want this.

" Disable audible bell because it's annoying.
set noerrorbells visualbell t_vb=

" Enable mouse support. You should avoid relying on this too much, but it can
" sometimes be convenient.
set mouse+=a

" Try to prevent bad habits like using the arrow keys for movement. This is
" not the only possible bad habit. For example, holding down the h/j/k/l keys
" for movement, rather than using more efficient movement commands, is also a
" bad habit. The former is enforceable through a .vimrc, while we don't know
" how to prevent the latter.
" Do this in normal mode...
nnoremap <Left>  :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up>    :echoe "Use k"<CR>
nnoremap <Down>  :echoe "Use j"<CR>
" ...and in insert mode
inoremap <Left>  <ESC>:echoe "Use h"<CR>
inoremap <Right> <ESC>:echoe "Use l"<CR>
inoremap <Up>    <ESC>:echoe "Use k"<CR>
inoremap <Down>  <ESC>:echoe "Use j"<CR>

3.安装和配置一个插件: ctrlp.vim.
–用 mkdir -p ~/.vim/pack/vendor/start 创建插件文件夹
–下载这个插件: cd ~/.vim/pack/vendor/start; git clone https://github.com/ctrlpvim/ctrlp.vim
–阅读这个插件的 文档。 尝试用 CtrlP 来在一个工程文件夹里定位一个文件, 打开 Vim, 然后用 Vim 命令控制行开始 :CtrlP.
–自定义 CtrlP: 添加 configuration 到你的 ~/.vimrc 来用按 Ctrl-P 打开 CtrlP

按照上面说明进行即可
4.练习使用 Vim, 在你自己的机器上重做 演示。
按照这个材料重做即可。

5.下个月用 Vim 完成_所有的_文件编辑。每当不够高效的时候,或者你感觉 “一定有一个更好的方式”时, 尝试求助搜索引擎,很有可能有一个更好的方式。如果你遇到难题,可以来我们的答疑时间或者给我们发邮件。

0

6.在其他工具中设置 Vim 快捷键 (见上面的操作指南)。

例如在VSCODE中可以下载插件,然后自定义。
7.进一步自定义你的 ~/.vimrc 和安装更多插件。
按需来就行,可以参考~gayhub~github来获得他人的分享。
8.(高阶)用 Vim 宏将 XML 转换到 JSON (例子文件)。 尝试着先完全自己做,但是在你卡住的时候可以查看上面 章节。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值
>