SlideShare a Scribd company logo
Vim and Python




Derek McLoughlin
Jolt Online Gaming
   8th June 2011
Overview
●   Intro
●   Why use Vim?
●   Basic Vim concepts
●   Vim is a Game
●   General Plugins
●   Python Plugins
●   How to Organise your plugins
●   Resources
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
Basic Concepts #1 - Modes
●   Vim is modal
●   It has 5 modes
    ●   Normal
    ●   Insert
    ●   Ex
    ●   Visual
    ●   Select
●   You'll find yourself pressing <ESC> a lot :-)
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
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.
Vim Leverages Unix
●   Example:
    ●   :%!sort
    ●   :'<,'>!sort
    ●   :%!awk '{print $3}'
    ●   :%!sed 's/foo/bar/'
General Plugins
NerdTree                  NerdCommenter
NerdTree                  NerdCommenter
Bufferlist                Matchit
Command-T                 SnipMate
Ack                       Fugative
Tagging & Tagbar          Extradite
DBExt                     Gitv
Rails.vim
Python Plugins
●   Python Match
●   RopeVim
●   PyFlakes
●   Pydoc
●   Pep-8
Organising Plugins
●   Old School – all plugins in same folder – a
    mess!
    ●   .vim
        -> doc
        -> ftplugin
        -> plugin
●   Use Pathogen
●   Use Vundle
Scripting Vim
●   Vim has an in-built scripting language
    ●   VimScript or VimL
●   It's ugly.
●   Use Python instead!
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
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.
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
Why Not Vim?
●   Terse
●   Modal
●   Steep-ish learning curve...
Learning curves of editors
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

More Related Content

PDF
Vim conf2019
PPTX
Vim Showcase
PDF
The State of PHP 2014 - Portsmouth Linux User Group (6th June 2014)
PDF
Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...
PDF
What Is This Continuous Delivery Thing Anyway? - PuppetConf 2013
PDF
WatPy talk
PDF
Vim and tmux
Vim conf2019
Vim Showcase
The State of PHP 2014 - Portsmouth Linux User Group (6th June 2014)
Releasing Puppet: Automating Packaging for Many Platforms or 'Make all the th...
What Is This Continuous Delivery Thing Anyway? - PuppetConf 2013
WatPy talk
Vim and tmux

Similar to Vim and Python (20)

KEY
Vim week
ODP
Vim and Python
PPTX
andrew's guide to vim
KEY
zhng your vim
PDF
Vim Notes
PDF
ODP
Augusta Linux User Group - Vim Introduction
PDF
PPTX
Vim survival guide
PDF
Byte of vim_v051
PDF
Unit 5 vim an advanced text editor
PDF
Useful Vim Plugins
PPTX
Introduction to Vim
PPTX
Vim - for newbies, by Roy Osherove
PDF
Vi survival guide
PPT
PDF
Vim Basics
PDF
vim brownbag - Richard forth
PDF
Vi Improved Vim First Edition Steve Oualline
PDF
Tuffarsi in vim
Vim week
Vim and Python
andrew's guide to vim
zhng your vim
Vim Notes
Augusta Linux User Group - Vim Introduction
Vim survival guide
Byte of vim_v051
Unit 5 vim an advanced text editor
Useful Vim Plugins
Introduction to Vim
Vim - for newbies, by Roy Osherove
Vi survival guide
Vim Basics
vim brownbag - Richard forth
Vi Improved Vim First Edition Steve Oualline
Tuffarsi in vim
Ad

More from Python Ireland (20)

PDF
Async I/O in Python
PDF
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
PDF
Python Ireland - Who, how, what
PPT
Object Orientation vs. Functional Programming in Python
PDF
What's the Scoop with Python 3?
PDF
Google App Engine in 40 minutes (the absolute essentials)
PDF
Introduction to Erlang for Python Programmers
PPT
Web-service based Mobile Geospatial Application Development using Python
PDF
Utopia Kingdoms scaling case. From 4 users to 50.000+
PPT
The Larch - a visual interactive programming environment
PDF
Python vs JLizard.... a python logging experience
PDF
Python Ireland Nov 2009 Talk - Appengine
ODP
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
PDF
Python Ireland Nov 2010 Talk: Unit Testing
PDF
Python Ireland Nov 2010 - RESTing with Django
ODP
Python Ireland Feb '11 Talks: Introduction to Python
PPTX
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
PDF
KEY
Python for cloud computing
ODP
IPython: The awesome python shell
Async I/O in Python
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland - Who, how, what
Object Orientation vs. Functional Programming in Python
What's the Scoop with Python 3?
Google App Engine in 40 minutes (the absolute essentials)
Introduction to Erlang for Python Programmers
Web-service based Mobile Geospatial Application Development using Python
Utopia Kingdoms scaling case. From 4 users to 50.000+
The Larch - a visual interactive programming environment
Python vs JLizard.... a python logging experience
Python Ireland Nov 2009 Talk - Appengine
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland Nov 2010 - RESTing with Django
Python Ireland Feb '11 Talks: Introduction to Python
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
Python for cloud computing
IPython: The awesome python shell
Ad

Vim and Python

  • 1. Vim and Python Derek McLoughlin Jolt Online Gaming 8th June 2011
  • 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.
  • 7. Vim Leverages Unix ● Example: ● :%!sort ● :'<,'>!sort ● :%!awk '{print $3}' ● :%!sed 's/foo/bar/'
  • 8. General Plugins NerdTree NerdCommenter NerdTree NerdCommenter Bufferlist Matchit Command-T SnipMate Ack Fugative Tagging & Tagbar Extradite DBExt Gitv Rails.vim
  • 9. Python Plugins ● Python Match ● RopeVim ● PyFlakes ● Pydoc ● Pep-8
  • 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
  • 15. Why Not Vim? ● Terse ● Modal ● Steep-ish learning curve...
  • 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