$30 off During Our Annual Pro Sale. View Details »

vim + tmux (Omaha Coding Women)

vim + tmux (Omaha Coding Women)

This is the revised and slightly modified presentation I gave at Omaha Coding Women on 4/27/15.

Nick Nisi

April 27, 2015
Tweet

More Decks by Nick Nisi

Other Decks in Technology

Transcript

  1. ❤ WebStorm
    1

    View Slide

  2. @nicknisi
    2

    View Slide

  3. 3

    View Slide

  4. ❤ WebStorm Vim
    4

    View Slide

  5. 5

    View Slide

  6. ❤ WebStorm Vim Minecraft
    6

    View Slide

  7. But I NEED an IDE
    7

    View Slide

  8. No you don't
    8

    View Slide

  9. Why vim?
    • highly customizable
    • runs everywhere
    • works with any programming
    languages
    • scriptable
    9

    View Slide

  10. 10

    View Slide

  11. start the timer
    11

    View Slide

  12. Install vim
    12

    View Slide

  13. (it's probably already there)
    13

    View Slide

  14. brew install macvim --override-system-vim
    14

    View Slide

  15. Features
    15

    View Slide

  16. Modal editing
    16

    View Slide

  17. Modal editing
    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
    17

    View Slide

  18. Normal mode
    18

    View Slide

  19. DON'T USE ARROW KEYS
    19

    View Slide

  20. DON'T USE THE MOUSE
    20

    View Slide

  21. You're a programmer.
    Strive to be lazy.
    21

    View Slide

  22. h j k l
    left up down right
    22

    View Slide

  23. • ^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
    23

    View Slide

  24. Elite!
    24

    View Slide

  25. The secret sauce
    25

    View Slide

  26. The secret sauce
    • text objects and motions
    • the DOT command
    • macros
    26

    View Slide

  27. Text objects and motions
    27

    View Slide

  28. Think of a file as more than individual characters
    28

    View Slide

  29. text objects
    • w - words
    • s - sentences
    • p - paragraphs
    • t - tags1
    1 tags available in XML/HTML files
    29

    View Slide

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

    View Slide

  31. Combine with comands
    31

    View Slide

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

    View Slide

  33. {command}{text object or motion}
    33

    View Slide

  34. diw
    delete in word
    34

    View Slide

  35. caw
    change all word
    35

    View Slide

  36. yi)
    yank all text inside parentheses
    36

    View Slide

  37. va"
    visually select all inside doublequotes
    Including doublequotes
    37

    View Slide

  38. Repetition
    The DOT command
    .
    38

    View Slide

  39. Repeat the last command
    39

    View Slide

  40. that's it
    40

    View Slide

  41. but it's powerful
    41

    View Slide

  42. 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
    42

    View Slide

  43. Try and make actions repeatable
    Practice it
    43

    View Slide

  44. Not everything is repeatable
    at least with the DOT command
    44

    View Slide

  45. MACROS
    45

    View Slide

  46. Macro
    A sequence of commands recorded to a register
    46

    View Slide

  47. Record a macro
    • q{register}
    • (do the things)
    • q
    Play a macro
    • @{register}
    47

    View Slide

  48. Plugins
    48

    View Slide

  49. Plugins
    • vundle - plugin manager
    • nerdtree - file drawer
    • ctrlp - fuzzy file finder
    • fugitive - git tool
    • syntastic - syntax checker / linter
    49

    View Slide

  50. But My IDE does more
    50

    View Slide

  51. Vim is extemely customizable
    Plugins tailor vim to your needs
    51

    View Slide

  52. But we can still do more
    52

    View Slide

  53. 53

    View Slide

  54. vim + tmux
    54

    View Slide

  55. tmux
    brew install tmux
    55

    View Slide

  56. What is tmux?
    • Terminal multiplexer
    • View and control multiple consoles
    • Preconfigure environments
    56

    View Slide

  57. tmux new-session -s {session-name}
    57

    View Slide

  58. tmux new-session -s pasta
    58

    View Slide

  59. ~/.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
    59

    View Slide

  60. There's a lot that tmux can do
    60

    View Slide

  61. Synchronize-panes
    61

    View Slide

  62. Create splits on the fly
    62

    View Slide

  63. tmux + vim = ❤
    63

    View Slide

  64. benmills/vimux
    Interact with tmux from vim
    64

    View Slide

  65. Execute commands from vim in a split
    :call VimuxRunCommand("grunt test")
    Map the commands to a key
    nmap z :call VimuxRunCommand("grunt test")
    65

    View Slide

  66. I ❤ vim
    and I think you will, too
    66

    View Slide

  67. Learn your editor well
    (even if it's not vim)
    67

    View Slide

  68. Don't copy someone else's configuration
    Make it your own
    68

    View Slide

  69. But share your configuration
    69

    View Slide

  70. dotfiles
    • Share your configuration
    • Steal ideas from others
    • nicknisi/dotfiles
    Others
    • bryanforbes/dotfiles
    • jason0x43/dotfiles
    70

    View Slide

  71. Keep practicing
    71

    View Slide


  72. https://github.com/nicknisi/vim-workshop
    72

    View Slide