(Level: Beginner)
Abstract: Vim makes for a great editing experience for Python projects. In this session Derek will show you:
- Vim basics and modes
- Vim plugins that are useful for - Python development
- How to organise your plugins
- How to script Vim with Python.
2. Overview
● Intro
● Why use Vim?
● Basic Vim concepts
● Vim is a Game
● General Plugins
● Python Plugins
● How to Organise your plugins
● Resources
3. Why Vim?
● It's fast.
● It's portable. Linux, Windows, Mac, DOS, VMS
● It's everywhere – even on production systems
● It's very configurable
● It's very extensible
4. Basic Concepts #1 - Modes
● Vim is modal
● It has 5 modes
● Normal
● Insert
● Ex
● Visual
● Select
● You'll find yourself pressing <ESC> a lot :-)
5. Basic Concepts #2 - Commands
● Commands follow a pattern:
Number + Command + Destination
● E.g.
● 5dw – delete 5 words
● 6w – move forward 6 words
● 7x – delete 7 characters
6. Vim is a Game
(that you play on text)
● When you play a PC game (e.g. Minecraft) you
forget that you need to press specific keys to do
something – WASD. After a while, those actions
are programmed into your finger muscles.
● You “do”. You don't “think”.
● You can practice Vim movements this with Vim
Tetris
● Movement keys are always on the right hand.
10. Organising Plugins
● Old School – all plugins in same folder – a
mess!
● .vim
-> doc
-> ftplugin
-> plugin
● Use Pathogen
● Use Vundle
11. Scripting Vim
● Vim has an in-built scripting language
● VimScript or VimL
● It's ugly.
● Use Python instead!
12. Example*
function! GetHTML()
python << EOF
import vim, BeautifulSoup, urllib
handle = urllib.urlopen(vim.current.line)
soup =
BeautifulSoup.BeautifulSoup(handle.read())
vim.current.buffer[:] =
soup.prettify().split('n')
EOF
endfunction
* I took this from:
http://www.builderau.com.au/program/python/soa/Extending-Vim-with-Python/0,2000064084,339283181,00.htm
13. Vim is Charityware
● Donations to Vim go to a charity that helps
orphans in Uganda.
● If you do like Vim and you feel it is making you
more productive, then please donate to this
charity.
● The details are on the Vim website.
14. Vim Resources
● Vim - www.vim.org
● VimCasts - www.vimcasts.org
● Vim Quick Reference Card -
● http://tnerual.eriogerg.free.fr/vim.html
● Jolt Online Gaming version!!!
● Books
● Hacking Vim - Packt Publishing
● Byte of Vim - http://www.swaroopch.com/notes/Vim
● Older online book -
ftp://ftp.vim.org/pub/vim/doc/book/vimbook-OPL.pdf
17. What to do if Vim isn't for you
● Notwithstanding the last slide...
● Try Emacs
● Seriously, it's a good editor.
● Org-mode is a great way to get into Emacs
gently
● Use the Emacs Starter Kit