Vim and PythonDerek McLoughlinJolt Online Gaming   8th June 2011
Overview●   Intro●   Why use Vim?●   Basic Vim concepts●   Vim is a Game●   General Plugins●   Python Plugins●   How to Or...
Why Vim?●   Its fast.●   Its portable. Linux, Windows, Mac, DOS, VMS●   Its everywhere – even on production systems●   Its...
Basic Concepts #1 - Modes●   Vim is modal●   It has 5 modes    ●   Normal    ●   Insert    ●   Ex    ●   Visual    ●   Sel...
Basic Concepts #2 - Commands●   Commands follow a pattern:    Number + Command + Destination●   E.g.    ●   5dw – delete 5...
Vim is a Game            (that you play on text)●   When you play a PC game (e.g. Minecraft) you    forget that you need t...
Vim Leverages Unix●   Example:    ●   :%!sort    ●   :<,>!sort    ●   :%!awk {print $3}    ●   :%!sed s/foo/bar/
General PluginsNerdTree                  NerdCommenterNerdTree                  NerdCommenterBufferlist                Mat...
Python Plugins●   Python Match●   RopeVim●   PyFlakes●   Pydoc●   Pep-8
Organising Plugins●   Old School – all plugins in same folder – a    mess!    ●   .vim        -> doc        -> ftplugin   ...
Scripting Vim●   Vim has an in-built scripting language    ●   VimScript or VimL●   Its ugly.●   Use Python instead!
Example*function! GetHTML()python << EOFimport vim, BeautifulSoup, urllibhandle = urllib.urlopen(vim.current.line)soup =Be...
Vim is Charityware●   Donations to Vim go to a charity that helps    orphans in Uganda.●   If you do like Vim and you feel...
Vim Resources●   Vim - www.vim.org●   VimCasts - www.vimcasts.org●   Vim Quick Reference Card -    ●   http://tnerual.erio...
Why Not Vim?●   Terse●   Modal●   Steep-ish learning curve...
Learning curves of editors
What to do if Vim isnt for you●   Notwithstanding the last slide...●   Try Emacs●   Seriously, its a good editor.●   Org-m...
Upcoming SlideShare
Loading in …5
×

Vim and Python

3,935 views

Published on

(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 Comments
2 Likes
Statistics
Notes
No Downloads
Views
Total views
3,935
On SlideShare
0
From Embeds
0
Number of Embeds
75
Actions
Shares
0
Downloads
15
Comments
2
Likes
2
Embeds 0
No embeds

No notes for slide

Vim and Python

  1. 1. Vim and PythonDerek McLoughlinJolt Online Gaming 8th June 2011
  2. 2. Overview● Intro● Why use Vim?● Basic Vim concepts● Vim is a Game● General Plugins● Python Plugins● How to Organise your plugins● Resources
  3. 3. Why Vim?● Its fast.● Its portable. Linux, Windows, Mac, DOS, VMS● Its everywhere – even on production systems● Its very configurable● Its very extensible
  4. 4. Basic Concepts #1 - Modes● Vim is modal● It has 5 modes ● Normal ● Insert ● Ex ● Visual ● Select● Youll find yourself pressing <ESC> a lot :-)
  5. 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. 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 dont “think”.● You can practice Vim movements this with Vim Tetris● Movement keys are always on the right hand.
  7. 7. Vim Leverages Unix● Example: ● :%!sort ● :<,>!sort ● :%!awk {print $3} ● :%!sed s/foo/bar/
  8. 8. General PluginsNerdTree NerdCommenterNerdTree NerdCommenterBufferlist MatchitCommand-T SnipMateAck FugativeTagging & Tagbar ExtraditeDBExt GitvRails.vim
  9. 9. Python Plugins● Python Match● RopeVim● PyFlakes● Pydoc● Pep-8
  10. 10. Organising Plugins● Old School – all plugins in same folder – a mess! ● .vim -> doc -> ftplugin -> plugin● Use Pathogen● Use Vundle
  11. 11. Scripting Vim● Vim has an in-built scripting language ● VimScript or VimL● Its ugly.● Use Python instead!
  12. 12. Example*function! GetHTML()python << EOFimport vim, BeautifulSoup, urllibhandle = urllib.urlopen(vim.current.line)soup =BeautifulSoup.BeautifulSoup(handle.read())vim.current.buffer[:] =soup.prettify().split(n)EOFendfunction* I took this from:http://www.builderau.com.au/program/python/soa/Extending-Vim-with-Python/0,2000064084,339283181,00.htm
  13. 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. 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
  15. 15. Why Not Vim?● Terse● Modal● Steep-ish learning curve...
  16. 16. Learning curves of editors
  17. 17. What to do if Vim isnt for you● Notwithstanding the last slide...● Try Emacs● Seriously, its a good editor.● Org-mode is a great way to get into Emacs gently● Use the Emacs Starter Kit

×