SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie Vim and Python: A Guide to Using Vim for Python Development

Useful Vim Plugins
Useful Vim PluginsUseful Vim Plugins
Useful Vim Pluginsanveo
 
Let's talk about neovim
Let's talk about neovimLet's talk about neovim
Let's talk about neovimShougo
 
Neosnippet.vim + Deoppet.nvim in Vim conf 2017
Neosnippet.vim + Deoppet.nvim in Vim conf 2017Neosnippet.vim + Deoppet.nvim in Vim conf 2017
Neosnippet.vim + Deoppet.nvim in Vim conf 2017Shougo
 
Puppet managed loadays
Puppet managed loadaysPuppet managed loadays
Puppet managed loadaysloadays
 
Creating a mature puppet system
Creating a mature puppet systemCreating a mature puppet system
Creating a mature puppet systemrkhatibi
 
Creating a Mature Puppet System
Creating a Mature Puppet SystemCreating a Mature Puppet System
Creating a Mature Puppet SystemPuppet
 
Kodar-lan - Text and editors Vi/Vim
Kodar-lan - Text and editors Vi/VimKodar-lan - Text and editors Vi/Vim
Kodar-lan - Text and editors Vi/VimTim Gremalm
 
Automating MySQL operations with Puppet
Automating MySQL operations with PuppetAutomating MySQL operations with Puppet
Automating MySQL operations with PuppetKris Buytaert
 
Debugging Web Apps on Real Mobile Devices
Debugging Web Apps on Real Mobile DevicesDebugging Web Apps on Real Mobile Devices
Debugging Web Apps on Real Mobile DevicesDale Lane
 
Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)Lorna Mitchell
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Docker, Inc.
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013dotCloud
 
Perl Continous Integration
Perl Continous IntegrationPerl Continous Integration
Perl Continous IntegrationMichael Peters
 
vim brownbag - Richard forth
vim brownbag - Richard forthvim brownbag - Richard forth
vim brownbag - Richard forthEdwardElric59
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo..."Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...Yandex
 
deoplete: The dark powered auto completion plugin for neovim
deoplete: The dark powered auto completion plugin for neovimdeoplete: The dark powered auto completion plugin for neovim
deoplete: The dark powered auto completion plugin for neovimShougo
 

Ähnlich wie Vim and Python: A Guide to Using Vim for Python Development (20)

Useful Vim Plugins
Useful Vim PluginsUseful Vim Plugins
Useful Vim Plugins
 
Let's talk about neovim
Let's talk about neovimLet's talk about neovim
Let's talk about neovim
 
Neosnippet.vim + Deoppet.nvim in Vim conf 2017
Neosnippet.vim + Deoppet.nvim in Vim conf 2017Neosnippet.vim + Deoppet.nvim in Vim conf 2017
Neosnippet.vim + Deoppet.nvim in Vim conf 2017
 
Puppet managed loadays
Puppet managed loadaysPuppet managed loadays
Puppet managed loadays
 
Creating a mature puppet system
Creating a mature puppet systemCreating a mature puppet system
Creating a mature puppet system
 
Creating a Mature Puppet System
Creating a Mature Puppet SystemCreating a Mature Puppet System
Creating a Mature Puppet System
 
Vim
VimVim
Vim
 
Kodar-lan - Text and editors Vi/Vim
Kodar-lan - Text and editors Vi/VimKodar-lan - Text and editors Vi/Vim
Kodar-lan - Text and editors Vi/Vim
 
Kick my mouse away
Kick my mouse awayKick my mouse away
Kick my mouse away
 
Small Screen Development
Small Screen DevelopmentSmall Screen Development
Small Screen Development
 
Automating MySQL operations with Puppet
Automating MySQL operations with PuppetAutomating MySQL operations with Puppet
Automating MySQL operations with Puppet
 
Debugging Web Apps on Real Mobile Devices
Debugging Web Apps on Real Mobile DevicesDebugging Web Apps on Real Mobile Devices
Debugging Web Apps on Real Mobile Devices
 
Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)
 
Tweakers Anonymous
Tweakers AnonymousTweakers Anonymous
Tweakers Anonymous
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
 
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
 
Perl Continous Integration
Perl Continous IntegrationPerl Continous Integration
Perl Continous Integration
 
vim brownbag - Richard forth
vim brownbag - Richard forthvim brownbag - Richard forth
vim brownbag - Richard forth
 
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo..."Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
"Lightweight Virtualization with Linux Containers and Docker". Jerome Petazzo...
 
deoplete: The dark powered auto completion plugin for neovim
deoplete: The dark powered auto completion plugin for neovimdeoplete: The dark powered auto completion plugin for neovim
deoplete: The dark powered auto completion plugin for neovim
 

Mehr von Python Ireland

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

Mehr von Python Ireland (20)

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

Vim and Python: A Guide to Using Vim for Python Development

  • 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