Hw03-Vim Editor
1. Complete vimtutor
lee@ubuntu:~/class/Missing-Semester/class-3$ vimtutor
Vimtutor is a simple tutorial for the beginner to learn how to use the editor with the most easy way. After I've been read about it, it pointed that vim need to learn in a long way.
2.Setting the basic vimrc
First download the file to the directory of you user.
lee@ubuntu:~$curl https://missing.csail.mit.edu/2020/files/vimrc > .vimrc
There is something by default as the vim started.
3. Install and configure a plugin ctrlp.vim
Install with the following commands and use it.
lee@ubuntu:~$ mkdir -p ~/.vim/pack/bencor/start
lee@ubuntu:~$ cd ~/.vim/pack/vendor/start
lee@ubuntu:~$ git clone https://github.com/ctrlpvim/ctrlp.vim
Customize the plugin by editing .vimrc file by studying the [document](ctrlp.vim/readme.md at master · ctrlpvim/ctrlp.vim (github.com)).
4. Redo demo in the class
def fizz_buzz(limit):
for i in range(limit):
if i % 3 == 0:
print('fizz')
if i % 5 == 0:
print('fizz')
if i % 3 and i % 5:
print(i)
def main():
fizz_buzz(10)
We will fix the following issues:
- Main is never called
- Starts at 0 instead of 1
- Prints “fizz” and “buzz” on separate lines for multiples of 15
- Prints “fizz” for multiples of 5
- Uses a hard-coded argument of 10 instead of taking a command-line argument
5. Macro
Convert XML to JSON (example file) using Vim macros. Try to do this on your own, but you can look at the macros section above if you get stuck.
-
GG dd and gg dd the first and the last line
-
press q and a to start recording macro
-
V select the line number 1 and r{ to replace to {
-
Jump to the
line and wd<$d<0 press "name" and somthing -
Jump to the
line do things like 3 -
do things like 2
-
jump to the next line
-
Stop recording to press q
-
999@a