Skip to content

VI VIM

Created: 2015-10-27 21:11:10 -0700 Modified: 2020-12-19 19:45:22 -0800

10/27/2015

VI apparently is VIM in most modern setups.

If I ever want to use VIM again, I should read this page:http://statico.github.io/vim.html

  • First setup

    • touch ~/.vimrc
    • vim ~/.vimrc
      • Type “syntax on” on the first line to get syntax highlighting.
      • Type “set number” to have line numbers on.
      • Type “set ai” to have auto-indenting on for programming. I believe this only tabs in newlines at the tab-level of the last line, i.e. it doesn’t tab in the next line if the previous line ended in ”{“.
    • Monokai color scheme
      • git clone https://github.com/sickill/vim-monokai.git
      • mkdir -p ~/.vim/colors
      • cp vim-monokai/colors/monokai.vim ~/.vim/colors
      • rm -rf vim-monokai <— this deletes the repo
      • vim ~/.vimrc
      • Add “colorscheme monokai” in here.
  • Shortcuts

    • = is for indentation, so you can enter visual-line mode with shift+V and then press = to fix indentation.
    • ”ciw” for changing a word with the cursor anywhere on that word
  • Commands

    • In general: ”:set foo” will turn something on, and ”:set nofoo” will turn it off.
    • ”:syntax on” is all you need to have syntax highlighting turned on based on the file extension.
    • ”:set paste” and ”:set nopaste” can be used when pasting things in a terminal, that way you don’t get weird tabbing (as pasting will actually type out each character individually).
    • Change line endings from CRLF to LF: ”:set ff=unix” (and then save)

Just do ”:set paste” before pasting.