Changing cold feet to a warm bath
- Intro
- Audience
- Structure
- Requirements
- This Repo
- 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
- Cut/Copy/Paste
- Visual mode
- Visual mode + motions
- 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...
- vimrc
- buffers
- windows
- plugins 28. Vim in other software 29. Credits and links 30. Images
- 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
- startvim
- vim-config
- Request for feedback
- [Links] (/README.md/#links)
- [Vim tips] (/README.md/#vim-tips)
- [Fun] (/README.md/#fun)
- [TODO] (/README.md/#todo)
- License
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.
This workshop is originaly developed 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 ;-).
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.
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.
Is created to easily distribute the example files and handouts of this workshop to the participants. Now it holds everything related.
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.
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.
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.
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.
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
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?
Then we start talking about modes. Vim is the only editor I'm aware of that's defaulting to command 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.
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.
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.
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.
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."
Show some operators. Explain that most of these (exept for deletions) put you into insert mode.
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.
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.
Then we continue with even more motions.
And those can be combined with operators too.
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).
Explain how to search. People like to know that regexes are supported here.
And how search can be combined with operators as well.
File: 4-boilerplate.html This is the second time to edit this file. People should be able to move arround quicker now.
At this point people should be begging for copy/paste commands. They retyped "navigation" a million times now.
Immediately explain 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.
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 can't really exist without motions.
After you've selected something you can also operate on it! Great!
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 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.
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?
Shows some basic text objects. Tell something about inner and around.
Shows some more 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".
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 lose interest and attention).
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.
A little explanation on vim buffers is useful. This subject is covered more thoroughly in the (yet to be created) advanced workshop.
A little explanation on vim splits is useful. This subject is covered more thoroughly in the (yet to be created) advanced workshop.
A little explanation on vim plugins is useful. This subject is covered more thoroughly in the (yet to be created) advanced workshop.
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.
This sheet shows a bunch of useful links.
All images used in the Impress presentation are located in this folder. Below a list of them and where I found them:
Jimi-Hendrix.jpg | fanpop.com |
achtergrond blauw.jpg | Typoography template and kindly recreated by my colleague Ronald van Zon |
achtergrond blauw.png | Typoography template and kindly recreated by my colleague Ronald van Zon |
achtergrond groen.jpg | Typography template |
adm-3a-hjkl-keyboard.jpg | Catonmat.net |
demo1.avi | Alexander Swen |
learning_curve-text-editors.jpg | Can't find origin |
Lear Siegler ADM-3A computer terminal.jpg | Catonmat.net |
repetitive tasks.png | Bruno Oliveira |
vim3d_the_editor.png | Ivan Kristianto |
vim-bottom.jpg | Screenshot created by Alexander Swen |
The repo contains a bunch of example files to let the participants play with during exercises. Most of them are found on internet and some are intentionally damaged.
Used in Exercise 2 to let participants change random text. This file was found on nl.lipsum.com.
File currently not used. Was added to show effect of word wrapping. This file was found on nl.lipsum.com.
File currently not used. Might be useful in future. This file was found on Sinatrarb.com.
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.
This file was originally used to demonstrate ci" and similar functions. This file was found on Katacasts' string_calculator Github repo.
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.
File that's used in Why Vim? demo.
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".
We created a config that has some useful 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.
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.
The last sheet contains some links to interesting websites. Here's that list.
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..