No description or website provided.
VimL Python HTML Other
Pull request Compare This branch is 37 commits ahead of nedap:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
files
presentation
vim-config
.gitignore
README.md
start_vim

README.md

Vim Workshop

Changing cold feet to a warm bath


  1. Intro
    1. Audience
    2. Structure
    3. Requirements
  2. This Repo
    1. Presentation
      1. Preparation
      2. Why Vim
      3. Learning is difficult
      4. History
      5. Vim GUI and don't panic
      6. Modes
      7. Undo/Redo/Repeat
      8. Motions
      9. Exercise 1: Getting familiar with some commands and the gui
      10. More motions
      11. Operators
      12. Operator + Motion 1
      13. Exercise 2: Get used to motions and operators
      14. Even more motions
      15. Operator + Motion 2
      16. Exercise 3: Not so efficient editing
      17. Searching
      18. Operator + search
      19. Exercise 4: Slightly more efficient editing
      20. Cut/Copy/Paste & Visual mode
        1. Cut/Copy/Paste
        2. Visual mode
        3. Visual mode + motions
        4. Visual mode + operators
      21. Exercise 5: Use visual mode to create a CSV file
      22. Search/Replace
      23. Exercise 6: Use Search/Replace to create a CSV file
      24. Text objects
      25. More text objects
      26. Operator + text objects
      27. If there's time left...
        1. vimrc
        2. buffers
        3. windows
        4. plugins
      28. Vim in other software
      29. Credits and links
      30. Images
    2. files
      1. 1-lorem.txt
      2. 2-lorem-wrapped.txt
      3. 3-sinatra.rb
      4. 4-boilerplate.html
      5. 5-string_calculator_spec.rb
      6. 6-digits.txt
      7. 7-markdown.txt
    3. startvim
    4. vim-config
  3. Request for feedback
  4. Links
    1. Vim tips
    2. Fun
  5. TODO
  6. License

Intro

We (that is Alexander Swen and Joël Stemmer) created this workshop to help our coding colleagues at Nedap to become more productive using Vim. This repo contains my continuated version of the original work we did at Nedap. It's a fork of Nedap's Vim workshop repo. It is my experience that it takes about three hours to give this workshop and I have good experiences with about 12 people in a classroom setting. You need every participant to have a workstation that has vim installed and a clone of this repo. I bought a PDF version of the Vim Cheat-sheet by Max Cantor. I recommend all participants to buy one. Max kindly gave me permission to give away prints of this sheet. So, if you're reading this because you consider to give this workshop, consider to buy that cheatsheet and distribute them as well.

Audience

This workshop is originaly developped for our colleagues at Nedap. They're programmers and sysadmins. Some of them never touched Vim, others use it occasionaly and some are experienced Vim users. Afterwards some of them started using Vim instead of their other editor, others improved their skills and work more efficient now. This workshop is now intended for people who want to use Vim but fear the learning curve and for people who do simple things in Vim but want to benefit more from the powerful features Vim has to offer. However, everytime I gave this workshop there was some bloke that I would classify as "highly experienced". And even that kind of guys learned something new they said afterwards. The workshop gives a structured overview of modes, motions and operators in such a way that the audience has an understanding of the mass of commands they see when they open vim for the 1st time. (or actually they only see that once they found the help command ;-).

Structure

The idea is that you explain people how they can work superfast with Vim. To do this you should use the presentation "vim.odp" and let people try what you explained in the "exercises". These are very important as I believe practicing what you just learned improves the persistancy of the knowledge. I also believe that people who just listen to a story for a while will remember far less than when they immediately get proof and see it's not that hard. That's why the practicefiles are included. At the moment not all of them are used. They can be used off course.

Requirements

To succesfully train people using Vim you need the following:

  • A deep understanding of all commands explained in the presentation.
  • A classroom style presentation room, with:
    • Enough tables and seats for the participants
    • Beamer
  • A computer (preferably a laptop) to run the LibreOffice Impress presentation on.
  • I like to use a Presenter to switch slides. This allows me to walk arround the classroom.

This Repo

Is created to easily distribute the example files and handouts of this workshop to the participants. Now it holds everything related.

Presentation

File called presentation/vim.odp. The presentation is here to support the explanations about Vim. It is created in LibreOffice Impress and has two different background colours: Blue for things the presenter has to tell and explain, green for exercises the participants need to do themselves. Exercises contain a few tasks and a reference of what I explained before.

Preparation

This slide informs users where to find this repo and (a bit) how to install Vim on their computer. It promises an USB stick to be available when no interwebs is there. (I never solely rely on working interwebs on public events). I recommend to start showing this sheet well in advance of the actual training if you have the chance to avoid very long delays when you want to start. This slide is followed by a splash slide that you can bring to front to draw attention and make clear you wish to start.

Why Vim

To give participants an idea of what they're going to learn and why Vim is still a cool editor after 35 years of development you let them count in their heads how much keystrokes it would take them in another editor (I allways use Notepad or, if the users really hate Windows Gedit for example) to make "This is another header" a header in this simple markdown example.

Learning is difficult

The picture of the learning curves of editors is a joke, but not without good background. Learning Vim can be a hurdle to take. However, once you know a litle bit you can already be working very fast, at least as fast as you did in your previous edittor before. A good read about this is A blog post by Yehuda Katz about his "learning Vim" experience.

History

A good read on the history is Peteris Krumins' article about the hjkl keys in Vim. I allways explain how the hjkl thing came into Vim. Tell a brief history of Vim. I always mention the following milestones:

  • 1976 Vi created as improvement over ex. (vi is short for Visual).
  • 1988 Bram Molenaar created 1st clone of Elvis on Amiga.
  • 1991 Vim released in the wild by Bram Molenaar. (Vim meant either "Vi Improved" or "Vi Imitated").
  • 1998 Syntax highlighting was added.
  • 2006 7.0 released
  • 2013-08-10: 7.4 released

Vim GUI and don't panic

Let's show the real stuff: the GUI. I took a screenshot once and pasted that and then lost it. That's why it's not listed in The images list. However this to show a bit what's where etc. I tell the people that there is a gvimrc option to get rid of the toolbar. Then the "don't panic" slide is here to show the commands I mention and first glimpse of the logic in commands. Emphasize on the detail that "q" and "wq" are abbreviations of complete commands. Tell that remembering a command is far more easy when you remember the word for it. "h" for help! is fairly obvious right?

Modes

Then we start talking about modes. Vim is the only editor I'm aware of that's defaulting to insert mode, moreover: I don't know any editor that has any other mode than "insertmode". The most of our work is not keying in text, it's more about "changing text". And that should be done using the whole bunch of nifty commands Vim has to offer. The first sheet explains the functions of the several modes and the second tells some ways of switching between them.

Undo/Redo/Repeat

Explain undo and redo commands. And that Vim keeps buffers of actions until you close the file. So the undo-/redobuffers are still available after you saved the file. Learn people immediately to stay as short as they can in Insert mode. A good reason is because each insert action should result in a undo/redo event. Another reason is that you don't make silly mistakes like having ":w" in your tekst, or "i" in a script. People love to hear about the dot command. And the slide "repeat action n times is great too" is here to explain another form of repeation.

Motions

They were already mentioned. But it is good to explain hjkl again. And I explain that (reminding the blog post of Yehuda) people should definitely not try to use solely hjkl motions but rather stay one arrow keys as long as the feel more comfortable there. However, point out that not having to leave the homerow is a big timesaver.

Exercise 1: Getting familiar with some commands and the gui

People are now listening to you for quite some time so it's time for their first steps. Let's summarize what we've learned so far. Let's see who knows the result of the commands on this slide. Then, of course a coffee break would be nice to have.

More motions

Three slides with more motions. I walk through most of them. The first one has a nice revelation for those who know about regex: some motions are similar to regular expressions. (at least 0 ^ $ are). Halfway zz reads "Center view on current {object}". This should be explained: "This actually means: redisplay the current line on center of current screen. The current window doesn't have to be covering the screen."

Operators

Show some operators. Explain that most of these (exept for deletions) put you into insert mode.

Operator + Motion 1

This is the most important part of the whole workshop: the power of combining operators and motions. Essentially the rest is more of this. All participants have to understand this before you continue.

Exercise 2: Get used to motions and operators

File: 1-lorem.txt Let's immediately try this. If they do exactly what's on the exercise slide participants run into a situation where they change not a real word but a comma. Results are not important here: just the feeling of 3j, c4w etc.

Even more motions

Then we continue with even more motions.

Operator + Motion 2

And those can be combined with operators too.

Exercise 3: Not so efficient editing

File: 4-boilerplate.html This is the first time to edit this file. People have to really dw and then retype (they don't know copy/paste yet).

Searching

Explain how to search. People like to know that regexes are supported here.

Operator + search

And how search can be combined with operators as well.

Exercise 4: Slightly more efficient editing

File: 4-boilerplate.html This is the second time to edit this file. People should be able to move arround quicker now.

Cut/Copy/Paste & Visual mode

At this point people should be begging for copy/paste commands. They retyped "navigation" a million times now.

Cut/Copy/Paste

Immediately tell yw to show that also yank can be combined with a motion. And tell the rest. pay some atention to yy. They all should note the similarity with cc/dd now. Then tell them that with this knowledge the previous two exercises would have been way easier.

Visual mode

Time for visual mode now. The visual block mode is quite unique. Only Sublime text has that function too (afaik). A nice example to show "select all": ggVG

Visual mode + motions

Visual mode can't realy exist without motions.

Visual mode + operators

After you've selected something you can also operate on it! great!

Exercise 5: use visual mode to create a CSV file

File: 6-digits.txt This file will be used twice as well: this time participants may only use visual mode to achieve the goal: create a CSV file. They should all ask if this can't be done using search and replace

Search/Replace

Search/replace is a real powertool. Simple things can be done very quick. Especially repetitive work is often a good candidate to be done using search/replace. Or rather "substitute" like it's called in awk/sed/perl and other tools.

Exercise 6: Use Search/Replace to create a CSV file

File: 6-digits.txt Let the participants use search/replace to change the file 6-digits.txt to a CSV file (they may choose their own separator). The following three commands (after removing lines 1,3 and last) should be sufficient:

:%s/^| //
:%s/ | /,/
:%s/   |//

Then, just for fun, show the power of search and replace by using:

:%s?\D\+\(\d\+\)\D\+\(\d\+\)\D\+?\1,\2?

Text objects

Shows some basic text objects. Tell something about inner and arround.

More text objects

Shows some more text objects.

Operator + text objects

Explains the power of combining operators and text objects. Some examples are shown on the slides and one can choose to add an exercise: use 3-sinatra.rb for example to let users change stuff between quotes or 4-boilerplate.html to let them try "cit".

If there's time left

4 bonus subjects. Only to be discussed when the clock and the audience's attention allow for it (the participants are learning stuff for quite a while at this point and I can imagine they loose interest and attention).

vimrc

An explanation of the vimrc config file and how one can try his modifications while editting. In the (yet to be created) advanced workshop the use of the command :options will help.

buffers

A little explanation on vim buffers is usefull. This subject is covered more deeply in the (yet to be created) advanced workshop.

windows

A little explanation on vim splits is usefull. This subject is covered more deeply in the (yet to be created) advanced workshop.

plugins

A little explanation on vim plugins is usefull. This subject is covered more deeply in the (yet to be created) advanced workshop.

Vim in other software

A short list of some other programs that support features from vim. The list is not exhaustive, just to give an impression. Recently "vifm" was added.

Credits and links

This sheet shows a bunch of usefull links.

Images

All images used in the Impress presentation are located in this folder. Below a list of them and where I found them:

Jimi-Hendrix.jpgfanpop.com
achtergrond blauw.jpgTypoography template and kindly recreated by my colleague Ronald van Zon
achtergrond blauw.pngTypoography template and kindly recreated by my colleague Ronald van Zon
achtergrond groen.jpgTypography template
adm-3a-hjkl-keyboard.jpgCatonmat.net
demo1.aviAlexander Swen
learning_curve-text-editors.jpgCan't find origin
Lear Siegler ADM-3A computer terminal.jpgCatonmat.net
repetitive tasks.pngBruno Oliveira
vim3d_the_editor.pngIvan Kristianto
vim-bottom.jpgScreenshot created by Alexander Swen

Files

The repo contains a bunch of examplefiles to let the participants play with during exercises. Most of them are found on internet and some are intentionally damaged.

1-lorem.txt

Used in Exercise 2 to let participants change random text. This file was found on nl.lipsum.com.

2-lorem-wrapped.txt

File currently not used. Was added to show effect of word wrapping. This file was found on nl.lipsum.com.

3-sinatra.rb

File currently not used. Might be usefull in future. This file was found on Sinatrarb.com.

4-boilerplate.html

Used in Exercise 3 and Exercise 4 to let participants experience how they can work more efficient using copy/paste. This file was found on Imakewebthings' deck.js Github repo.

5-string_calculator_spec.rb

This file was originally used to demonstrate ci" and similar functions. This file was found on Katacasts' string_calculator Github repo.

6-digits.txt

File used in Exercise 5 and Exercise 6 to demonstrate how easy you can change a lot of lines at ones using visual mode and how to be even more efficient using Search/Replace.

7-markdown.txt

File that's used in Why Vim? demo.

startvim

This script is created to make it easy for Linux and Mac users to start vim with the specific config for this workshop. It tries to either start mvim or gvim. For Windows users there's no help... This script can be improved to work better on macs as on some of them there has to be a symlink to the vim executable from the homedir before it's found by "which".

vim-config

We created a config that has some usefull default settings. This is to make sure that everyone participating in the workshop has the same settings and to avoid strange behaviour because of peoples own settings. I strongly recommend to encourage the use of this config during the workshop, even for experienced users.

Request for feedback

I would highly appreciate feedback on this workshop. Especially if you attended one of my workshops I like to improve both this workshop and my training skillz. You can contact me via Mail.

Links

The last sheet contains some links to interesting websites. Here's that list.

Vim tips

Fun

Todo

License

Creative Commons License
Vim workshop by Alexander Swen is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at https://github.com/nedap/vim-workshop. It was created by Alexander Swen & Joël Stemmer for Nedap N.V..