0%

[Missing Semester in CS] Editors (Vim)

Exercise

  1. Complete vimtutor. Note: it looks best in a
    80x24 (80 columns by 24 lines)
    terminal window.

    1
    $ vimtutor

    Really fantasitc learning material. Also remember the notes inside the tutor file: You should be learning by doing, not memorization.

  2. Download our basic vimrc and save it to ~/.vimrc. Read
    through the well-commented file (using Vim!), and observe how Vim looks and
    behaves slightly differently with the new config.

Just want to mention some great educational commands:

1
2
3
4
nnoremap <Left>  :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>

Every time we want to use direction key, they will disable and tell us not to do that.

  1. Install and configure a plugin:
    ctrlp.vim.
    1. Create the plugins directory with mkdir -p ~/.vim/pack/vendor/start
    2. Download the plugin: cd ~/.vim/pack/vendor/start; git clone https://github.com/ctrlpvim/ctrlp.vim
    3. Read the
      documentation
      for the plugin. Try using CtrlP to locate a file by navigating to a
      project directory, opening Vim, and using the Vim command-line to start
      :CtrlP.
      1. Customize CtrlP by adding
        configuration
        to your ~/.vimrc to open CtrlP by pressing Ctrl-P.
1
2
3
$ cd ~/.vim
$ git clone https://github.com/ctrlpvim/ctrlp.vim.git bundle/ctrlp.vim
$ vim ~/.vimrc # setting the config in vimrc
  1. To practice using Vim, re-do the Demo from lecture on your own
    machine.
  2. Use Vim for all your text editing for the next month. Whenever something
    seems inefficient, or when you think “there must be a better way”, try
    Googling it, there probably is.
  3. Configure your other tools to use Vim bindings (see instructions above).

Here is a list of commonly used plugins for vim user.

  1. Further customize your ~/.vimrc and install more plugins.
  2. (Advanced) 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.

Follow the instruction is enough to reproduce. And you will find it exciting when the editor programmably works for you. Completely reduce the repetition!