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

Similar to Vim and Python (20)

PDF
Useful Vim Plugins
anveo
 
PDF
Let's talk about neovim
Shougo
 
ODP
Neosnippet.vim + Deoppet.nvim in Vim conf 2017
Shougo
 
PDF
Puppet managed loadays
loadays
 
PDF
Creating a Mature Puppet System
Puppet
 
PDF
Creating a mature puppet system
rkhatibi
 
PDF
Vim
dstarr009
 
PDF
Kodar-lan - Text and editors Vi/Vim (2013-06-15)
Tim Gremalm
 
PDF
Kick my mouse away
Xatierlike Lee
 
KEY
Small Screen Development
Ralph von der Heyden
 
ODP
Automating MySQL operations with Puppet
Kris Buytaert
 
PDF
Debugging Web Apps on Real Mobile Devices
Dale Lane
 
PDF
Passing the Joel Test in the PHP World (phpbnl10)
Lorna Mitchell
 
KEY
Tweakers Anonymous
John Anderson
 
PDF
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Docker, Inc.
 
PDF
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
dotCloud
 
PDF
Perl Continous Integration
Michael Peters
 
PDF
vim brownbag - Richard forth
EdwardElric59
 
PDF
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
Yandex
 
PDF
deoplete: The dark powered auto completion plugin for neovim
Shougo
 
Useful Vim Plugins
anveo
 
Let's talk about neovim
Shougo
 
Neosnippet.vim + Deoppet.nvim in Vim conf 2017
Shougo
 
Puppet managed loadays
loadays
 
Creating a Mature Puppet System
Puppet
 
Creating a mature puppet system
rkhatibi
 
Kodar-lan - Text and editors Vi/Vim (2013-06-15)
Tim Gremalm
 
Kick my mouse away
Xatierlike Lee
 
Small Screen Development
Ralph von der Heyden
 
Automating MySQL operations with Puppet
Kris Buytaert
 
Debugging Web Apps on Real Mobile Devices
Dale Lane
 
Passing the Joel Test in the PHP World (phpbnl10)
Lorna Mitchell
 
Tweakers Anonymous
John Anderson
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Docker, Inc.
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
dotCloud
 
Perl Continous Integration
Michael Peters
 
vim brownbag - Richard forth
EdwardElric59
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
Yandex
 
deoplete: The dark powered auto completion plugin for neovim
Shougo
 

More from Python Ireland (20)

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