Skip to content

Latest commit

 

History

History
174 lines (111 loc) · 3.19 KB

presentation.md

File metadata and controls

174 lines (111 loc) · 3.19 KB
title separator verticalSeparator revealOptions transition
Modal editing with Vim
<!--s-->
<!--v-->
fade

Modal editing with Vi & Vim

presented by notarock

Agenda

  • What's vim anyway? What about this talk?
  • Modes
  • Thinking in vim
  • Ex/Sed commands
  • Additionnal ressources

What I will talk about

  • Help you with the initial "Learning curve"!

learning-curbe

What I will not talk about

  • Implementations like neovim, evil-mode, IDE plugins, etc.
  • Vimscript, vimrc and plugins

What's vim?

Sharp knife

  • Modal text editor (More about this later!)
  • Present on most *nix systems (If not vim, vi is)
  • Can be tailored to your needs
  • Fast!

Improving on an older, proven editor

  • VIM stands for Vi Improved (1991)
  • Vi stands for Visual Editor (1976)
  • ex stands for Extended (1970s)

Uses buffers to edit files

  • Load file, Make edits, Write to file.
  • Load multiple files
  • Does not care about file size at all!

Modes

Normal mode Insert mode Visual mode Command mode
Navigation Write characters Select characters Execute commands

Normal mode

  • Spend more than 80% of your time here
  • Press esc to enter normal mode
  • Almost every keys are mapped to a motion or an action.
  • Access other modes from here

Insert mode

  • Type text into the buffer
  • Press i to enter insert mode

Visual mode

  • v : character-wise visual mode
  • V : line-wise visual mode
  • Ctrl-v : block-wise visual mode

Command/Ex mode

  • : to start typing a command from normal mode
  • Ctrl-o : to type commands from insert mode
  • Syntax is similar to sed
ex -s +%s/127/128/g +%p +q! /etc/hosts
sed s/127/128/g /etc/hosts

Thinking in vim

  • You don't "remember" shortcuts.
  • You apply commands in order to achieve editing goals.
  • Keybindings are mnemonic. (a is for append, etc.)

Type of actions in normal mode

  • Motion
  • Command
  • Operators
  • Extras (e.g. Leader key)

Graphical cheat sheet

<number><command><text object or motion>
  • Can be saved in macros!
  • Can be applied to multiple lines with the :norm command!

Ex/Sed commands

Some basics

Write Quit Edit Read
:w :q :e :r

Common uses for commands

  • :s/Find-Word/Replace-Word/gc

Commands can be used for...

  • Interracting with buffers
  • Interracting with tabs/windows
  • Interracting with registers (Clipboard)
  • Get help

Additionnal ressources