LNCD

Table of Contents

  • LNCD Home
  • Administration
  • Notebooks
  • Journal Club Presentations
  • Publications
  • Current Projects
  • Completed Projects
  • Current Grants
  • Datasets by Project
  • Brain ROIs and Measures
  • ️Tools And Methods
  • Big Data
  • RA Homepage
  • Recent Changes
  • Maintenance
  • Site Map
  • Random Page
LNCD
Docs » Vim

Vim

vim is a modal editor (improving on vi). It can run without graphics, is ubiquitous, powerful, and efficient but is an acquired skill.

MIT's “missing semester” has an excellent summary of vim functions video and notes. Vim’s design is based on the idea that a lot of programmer time is spent reading, navigating, and making small edits, as opposed to writing long streams of text. For this reason, Vim has multiple operating modes.

  1. Normal: for moving around a file and making edits
  2. Insert: for inserting text
  3. Replace: for replacing text
  4. Visual (plain, line, or block): for selecting blocks of text
  5. Command-line: for running a command
  • vimtutor is a program included with vim that will guide you through usage – run it from the command line.
  • vim-wiki

Commands

  1. vim $filename → opens a file in vim. If that file doesn't exist or you opened it in the wrong filepath, you will see an empty blank vim that says [NEW] at the bottom
  2. i → puts you in insert mode so you can freely type and move your cursor around. Says – INSERT – in bottom left.
  3. esc → gets you out of insert mode
  4. :set nu shows you line numbers

move around

  1. 0 or Home puts your cursor to the beginning of the line (in command mode)
  2. $ or End puts your cursor to the end of the line (in command mode)
  3. Shift + i puts your cursor to the beginning of the line and opens insert mode
  4. Shift + a puts your cursor to the end of the line and opens insert mode
  5. o opens insert mode on a new line below your cursor
  6. up and down arrows move you up and down each line but to move between lines click g then up or down arrow
  7. u undo last change (in command mode)

Copy and paste

  • Click v to put you in visual mode
  • to cut- move your cursor to highlight the words you want to cut and press d
  • to copy- move your cursor to highlight the words you want to copy and press y
  • move your cursor to where you want to paste words and press p

close vim temporarily

  • Ctrl + z puts the vim window to “sleep” and brings you back to the terminal
  • fg brings you from the terminal back into the last script in vim you were working on

exit

  • :q → quits vim
  • :wq → saves what you wrote and quits vim
  • :q! → does not save what you wrote and quits vim
Previous Next