Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Latest commit

 

History

History
443 lines (260 loc) · 6.96 KB

vim-workshop.md

File metadata and controls

443 lines (260 loc) · 6.96 KB

slidenumbers: true

[fit] ❤️ WebStorm



fit


[fit] ❤️ WebStorm Vim


fit


[fit] ❤️ WebStorm Vim Minecraft


[fit] But I NEED an IDE


[fit] No you don't


[fit] Why vim?

fit left

  • highly customizable
  • runs everywhere
  • works with any programming languages
  • scriptable

inline


start the timer


[fit] Install vim

175%


[fit] (it's probably already there)


[fit] brew install macvim --override-system-vim


[fit] Features


[fit] Modal editing


[fit] Modal editing

[fit] Change the meaning of the keys in each mode of operation

  • Normal mode - navigate the structure of the file
  • Insert mode - editing the file
  • Visual mode - highlight portions of the file to manipulate at once
  • Ex mode - command mode

[fit] Normal mode


[fit] DON'T USE ARROW KEYS


[fit] DON'T USE THE MOUSE


You're a programmer. Strive to be lazy.


[fit] h j k l

[fit] left down up right


  • ^E - scroll the window down
  • ^Y - scroll the window up
  • ^F - scroll down one page
  • ^B - scroll up one page
  • H - move cursor to the top of the window
  • M - move cursor to the middle of the window
  • L - move cursor to the bottom of the window
  • gg - go to top of file
  • G - go to bottom of file

[fit] Elite!


The secret sauce


The secret sauce

  • text objects and motions
  • the DOT command
  • macros


[fit] Text objects and motions


[fit] Think of a file as more than individual characters


[fit] text objects

  • w - words
  • s - sentences
  • p - paragraphs
  • t - tags1

left


[fit] Motions

  • a- all
  • i - in
  • t - 'til
  • f - find forward
  • F - find backward

right


[fit] Combine with comands


[fit] Commands

  • d - delete (also cut)
  • c - change (delete, then place in insert mode)
  • y - yank (copy)
  • v - visually select

right fit


[fit] {command}{text object or motion}


[fit] diw

[fit] delete in word


[fit] caw

[fit] change all word


[fit] yi)

[fit] yank all text inside parentheses


[fit] va"

[fit] visually select all inside doublequotes

Including doublequotes


[fit] Repetition

[fit] The DOT command

.


[fit] Repeat the last command


[fit] that's it


[fit] but it's powerful


[fit] Additional commands

  • dd / yy - delete/yank the current line
  • D / C - delete/change until end of line
  • ^ / $ - move to the beginning/end of line
  • I / A - move to the beginning/end of line and insert
  • o / O - insert new line above/below current line and insert

[fit] Try and make actions repeatable

[fit] Practice it


[fit] Not everything is repeatable

[fit] at least with the DOT command


[fit] MACROS


[fit] Macro

[fit] A sequence of commands recorded to a register


Record a macro

  • q{register}
  • (do the things)
  • q

Play a macro

  • @{register}

left


[fit] Plugins


Plugins


[fit] But My IDE does more


[fit] Vim is extemely customizable

[fit] Plugins tailor vim to your needs


[fit] But we can still do more



[fit] vim + tmux


[fit] tmux

[fit] brew install tmux


[fit] What is tmux?

  • Terminal multiplexer
  • View and control multiple consoles
  • Preconfigure environments

[fit] tmux new-session -s {session-name}


[fit] tmux new-session -s pasta


[fit] ~/.tmux.conf - tmux configuration

  • configure tmux
# unbind default prefix and set it to Ctrl+a
unbind C-b
set -g prefix C-a
bind C-a send-prefix

inline 125%

right fit


[fit] There's a lot that tmux can do


[fit] Synchronize-panes

fit


[fit] Create splits on the fly

fit


[fit] tmux + vim = ❤️


Interact with tmux from vim


[fit] Execute commands from vim in a split

:call VimuxRunCommand("grunt test")

[fit] Map the commands to a key

nmap <leader>z :call VimuxRunCommand("grunt test")<cr>

[fit] I ❤️ vim

[fit] and I think you will, too


[fit] Learn your editor well

[fit] (even if it's not vim)


[fit] Don't copy someone else's configuration

[fit] Make it your own


[fit] But share your configuration


[fit] dotfiles

Others

left


[fit] Keep practicing


[fit] ❤️

Footnotes

  1. tags available in XML/HTML files