SlideShare a Scribd company logo
1 of 22
VIM and Python - Tips and Tricks




                          http://xkcd.com/378/
Getting Around

h/j/k/l
gg and G – start/end of buffer
^ - first non-blank character in current line
$ - last character on current line
CTRL-u / CTRL-d – page up / page down
:n – go to line number n.
H/M/L – go to first/middle/last line on screen*
% - jump to corresponding bracket [] {} ()
Marks

m followed by a letter to set a mark
` followed by the letter – jump to that mark
:marks will list current marks
Vim has some special marks (a few examples):
  `. - jump to position where the last change occured
  `` - jump back to position where you jumped from
lots more found in :help `
Making Changes

y/d/c – yank/delete/change
Y/D/C – same as above, but specifies line*
p/P – paste before/after
combine with movements:
  dw – delete word
  cw – change word
  dG – delete from cursor to end of file
  c`a – change from cursor to mark a
Making Changes
y/d/c – yank/delete/change
Y/D/C – same as above, but specifies line*
p/P – paste after/before
x/r – delete/replace single character
combine with movements:
  dw – delete word
  cw – change word
  dG – delete from cursor to end of file
  c`a – change from cursor to mark a
use the . character to repeat last command
Visual Mode

v – enter visual mode
V – enter visual mode, but operate on a line
CTRL-v -enter visual mode, operate on a column
  Use I to change all columns at once
combine with y/d/c for even more fun
Text Objects

used after an operator or visual mode
i – inner / a – ambient
  a' / i' – operate on block of ''
  a( / i( - operate of block of ()
  a{ / i{ - operate of block of {}
  at / it – operate of html or xml tags
Search

/ or ? - for a basic search (forward or backward)
  I recommend :set ignore case, :set smartcase and
     :set incsearch
  n to repeat search, or N to repeat in opposite
    direction
*/# - find next/previous of word under cursor
[I – list lines with word under cursor
  set up a map to make this easier:
  :map <space>f [I:let nr = input("Which one:
    ")<Bar>exe "normal " . nr ."[t"<CR>
Undos

u – undo, CTRL-R – redo
see also: undo-branches
time travel
  :earlier Ns, m, h
  :later Ns,m,h
  Can't jump to the future when the code is already
   done, sorry. Hoping for that feature in Vim 8
Splitting Windows

:sp -horizontal split
:vs – vertical split
:new
CTRL-w + movement to move between windows
I remap spacebar for easier commands
Configuration

.vimrc – global settings
.vim directory - plugins, color schemes, syntax
  definitions, etc
browse github for ideas, or just fork one you like
:set – see your current settings
don't be afraid to consult :help to see what things
 do
Config Examples

filtype plugin on – recoginize .py as python
filtype indent on – proper indentation (more on
   this later)
set nu – turn line numbers on
set ruler – see where you are in the file
set t_Co=256 – 256 colors
cmap w!! %!sudo tee > /dev/null %
  made changes to a read-only file? This mapping
   allows you to use :w!! to save using sudo
More Config Examples

au BufReadPost * if line("'"") > 0 && line("'"") <=
 line("$")|execute("normal `"")|endif
  jumps cursor to last edited position on file open
set pastetoggle=<F10>
  easy way to shift to paste mode to not screw up
   indentation
nmap <silent> <F6> :set number!<CR>
  turn line numbers on/off
set iskeyword-=-
  use dash as a word seperator
Indentation

My biggest hang-up when I started with python
Found a python indent file that works pretty well
  Found in .vim/after/indent/
  Autoindents/unindents around keywords
Various other indent definitions available
 (djangohtml is another I use)
= command will re-indent
use > and < to indent keys
Autocomplete

<tab> invokes autocomplete
  Use options wildmode and wildmenu to change how
   this works (I use list:longest,full)
Also work on filenames/directories (:e <tab>)
There are other forms of autocomplete:
  Omnicomplete – Heuristics based completion, I
   haven't had much luck
  pydiction plugin – keyword/modules
tags

I map F4 to rebuild tags file using ctags
CTRL-] - jump to tag under cursor
CTRL-T – return to where you came from
:tag <tagname> - jump to a tag
If there are multiple matches, you select from a
   list
taglist is another useful plugin to view the tags in
  the current file
NERDtree

Popular file explorer
Opens in a new window, which can be re-sized
 and customised
Supports bookmarks
I prefer to just use :e + <tab>
SelectBuf


Similar to a file explorer, but limited to buffers
  already open
A must-have if you normally operate many
 buffers at once
flake-8

wrapper for flake8 (must install seperately)
  PyFlakes
  PEP8
  complexity checker
Can configure to ignore errors
I map to F5, as I also use makeprg for other
  languages using the same key
Doxygen

Generate comment skeletons
  :DoxLic - License
  :DoxAuth - Author
  :Dox - function/class block headers
  Works well out of the box, but config options available
Other Plugins to Check Out

vimpdb
commandT
project
vcscommand
OScan
snippets
netrw
scratch
Resources

http://www.tuxfiles.org/linuxhelp/vimcheat.html
http://www.vim.org/scripts/index.php
http://www.pixelbeat.org/vim.tips.html
http://www.catswhocode.com/blog/100-vim-command
http://www.reddit.com/r/vim/

More Related Content

What's hot

The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersAlessandro Sanino
 
Writing multi-language documentation using Sphinx
Writing multi-language documentation using SphinxWriting multi-language documentation using Sphinx
Writing multi-language documentation using SphinxMarkus Zapke-Gründemann
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programmingMahmoud Masih Tehrani
 
PyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 TutorialPyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 TutorialJustin Lin
 
Happy Go Programming Part 1
Happy Go Programming Part 1Happy Go Programming Part 1
Happy Go Programming Part 1Lin Yo-An
 
Introduction to Clime
Introduction to ClimeIntroduction to Clime
Introduction to ClimeMosky Liu
 
Dive into Pinkoi 2013
Dive into Pinkoi 2013Dive into Pinkoi 2013
Dive into Pinkoi 2013Mosky Liu
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from DataMosky Liu
 
A Look at Command Line Swift
A Look at Command Line SwiftA Look at Command Line Swift
A Look at Command Line SwiftJoshuaKaplan22
 
Practicing Python 3
Practicing Python 3Practicing Python 3
Practicing Python 3Mosky Liu
 
Fluentd Hacking Guide at RubyKaigi 2014
Fluentd Hacking Guide at RubyKaigi 2014Fluentd Hacking Guide at RubyKaigi 2014
Fluentd Hacking Guide at RubyKaigi 2014Naotoshi Seo
 
Debugging concurrency programs in go
Debugging concurrency programs in goDebugging concurrency programs in go
Debugging concurrency programs in goAndrii Soldatenko
 
Learning Git with Workflows
Learning Git with WorkflowsLearning Git with Workflows
Learning Git with WorkflowsMosky Liu
 
Practical Example of grep command in unix
Practical Example of grep command in unixPractical Example of grep command in unix
Practical Example of grep command in unixJavin Paul
 
Python debugging techniques
Python debugging techniquesPython debugging techniques
Python debugging techniquesTuomas Suutari
 
Building robust and friendly command line applications in go
Building robust and friendly command line applications in goBuilding robust and friendly command line applications in go
Building robust and friendly command line applications in goAndrii Soldatenko
 
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modulesPython Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modulesP3 InfoTech Solutions Pvt. Ltd.
 

What's hot (20)

The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
 
Writing multi-language documentation using Sphinx
Writing multi-language documentation using SphinxWriting multi-language documentation using Sphinx
Writing multi-language documentation using Sphinx
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
A Python Tutorial
A Python TutorialA Python Tutorial
A Python Tutorial
 
Go. why it goes v2
Go. why it goes v2Go. why it goes v2
Go. why it goes v2
 
PyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 TutorialPyCon Taiwan 2013 Tutorial
PyCon Taiwan 2013 Tutorial
 
Happy Go Programming Part 1
Happy Go Programming Part 1Happy Go Programming Part 1
Happy Go Programming Part 1
 
Introduction to Clime
Introduction to ClimeIntroduction to Clime
Introduction to Clime
 
Dive into Pinkoi 2013
Dive into Pinkoi 2013Dive into Pinkoi 2013
Dive into Pinkoi 2013
 
Learning Python from Data
Learning Python from DataLearning Python from Data
Learning Python from Data
 
A Look at Command Line Swift
A Look at Command Line SwiftA Look at Command Line Swift
A Look at Command Line Swift
 
Practicing Python 3
Practicing Python 3Practicing Python 3
Practicing Python 3
 
Fluentd Hacking Guide at RubyKaigi 2014
Fluentd Hacking Guide at RubyKaigi 2014Fluentd Hacking Guide at RubyKaigi 2014
Fluentd Hacking Guide at RubyKaigi 2014
 
System Programming and Administration
System Programming and AdministrationSystem Programming and Administration
System Programming and Administration
 
Debugging concurrency programs in go
Debugging concurrency programs in goDebugging concurrency programs in go
Debugging concurrency programs in go
 
Learning Git with Workflows
Learning Git with WorkflowsLearning Git with Workflows
Learning Git with Workflows
 
Practical Example of grep command in unix
Practical Example of grep command in unixPractical Example of grep command in unix
Practical Example of grep command in unix
 
Python debugging techniques
Python debugging techniquesPython debugging techniques
Python debugging techniques
 
Building robust and friendly command line applications in go
Building robust and friendly command line applications in goBuilding robust and friendly command line applications in go
Building robust and friendly command line applications in go
 
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modulesPython Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modules
 

Viewers also liked

الكتاب المقدس العهد الجديد - رسالة بطرس الرسول الاولى
الكتاب المقدس   العهد الجديد - رسالة بطرس الرسول الاولىالكتاب المقدس   العهد الجديد - رسالة بطرس الرسول الاولى
الكتاب المقدس العهد الجديد - رسالة بطرس الرسول الاولىIbrahimia Church Ftriends
 
Los espiritus del bosque
Los espiritus del bosqueLos espiritus del bosque
Los espiritus del bosqueada48salamanca
 
The sacrament of penance
The sacrament of penanceThe sacrament of penance
The sacrament of penanceDolores Vasquez
 
SCCE Processors and GDPR
SCCE Processors and GDPRSCCE Processors and GDPR
SCCE Processors and GDPRRobert Bond
 
Financial & mgt. accounting
Financial & mgt. accountingFinancial & mgt. accounting
Financial & mgt. accountingRohit Mishra
 
Ack prez mlrng
Ack prez mlrngAck prez mlrng
Ack prez mlrnglleedavis
 
Inv pres q22014_-_final
Inv pres q22014_-_finalInv pres q22014_-_final
Inv pres q22014_-_finalCNOServices
 
M2M Framework December 2012
M2M Framework December 2012M2M Framework December 2012
M2M Framework December 2012Chris Estes
 
Ag 1 source-FWAA
Ag 1 source-FWAAAg 1 source-FWAA
Ag 1 source-FWAAAg 1 Source
 
Later People of the Fertile Crescent
Later People of the Fertile CrescentLater People of the Fertile Crescent
Later People of the Fertile Crescentssclasstorremar
 
iEnglish workshop 4
 iEnglish workshop 4 iEnglish workshop 4
iEnglish workshop 4dearjili
 

Viewers also liked (17)

06 chapter 1
06 chapter 106 chapter 1
06 chapter 1
 
Evaluación de centros educativos
Evaluación de centros educativosEvaluación de centros educativos
Evaluación de centros educativos
 
الكتاب المقدس العهد الجديد - رسالة بطرس الرسول الاولى
الكتاب المقدس   العهد الجديد - رسالة بطرس الرسول الاولىالكتاب المقدس   العهد الجديد - رسالة بطرس الرسول الاولى
الكتاب المقدس العهد الجديد - رسالة بطرس الرسول الاولى
 
Los espiritus del bosque
Los espiritus del bosqueLos espiritus del bosque
Los espiritus del bosque
 
Slides day two
Slides   day twoSlides   day two
Slides day two
 
Facebook
FacebookFacebook
Facebook
 
The sacrament of penance
The sacrament of penanceThe sacrament of penance
The sacrament of penance
 
SCCE Processors and GDPR
SCCE Processors and GDPRSCCE Processors and GDPR
SCCE Processors and GDPR
 
Financial & mgt. accounting
Financial & mgt. accountingFinancial & mgt. accounting
Financial & mgt. accounting
 
Ack prez mlrng
Ack prez mlrngAck prez mlrng
Ack prez mlrng
 
Taiwan (2016)
Taiwan (2016)Taiwan (2016)
Taiwan (2016)
 
Inv pres q22014_-_final
Inv pres q22014_-_finalInv pres q22014_-_final
Inv pres q22014_-_final
 
M2M Framework December 2012
M2M Framework December 2012M2M Framework December 2012
M2M Framework December 2012
 
Ciri-ciri Ikan Hiasan
Ciri-ciri Ikan HiasanCiri-ciri Ikan Hiasan
Ciri-ciri Ikan Hiasan
 
Ag 1 source-FWAA
Ag 1 source-FWAAAg 1 source-FWAA
Ag 1 source-FWAA
 
Later People of the Fertile Crescent
Later People of the Fertile CrescentLater People of the Fertile Crescent
Later People of the Fertile Crescent
 
iEnglish workshop 4
 iEnglish workshop 4 iEnglish workshop 4
iEnglish workshop 4
 

Similar to Vim and Python

DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foobrian_dailey
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentationbrian_dailey
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1Workshop on command line tools - day 1
Workshop on command line tools - day 1Leandro Lima
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing toolsroot_fibo
 
List command linux fidora
List command linux fidoraList command linux fidora
List command linux fidoraJinyuan Loh
 
Terminal linux commands_ Fedora based
Terminal  linux commands_ Fedora basedTerminal  linux commands_ Fedora based
Terminal linux commands_ Fedora basedNavin Thapa
 
CMake Tutorial
CMake TutorialCMake Tutorial
CMake TutorialFu Haiping
 
Unix Trainning Doc.pptx
Unix Trainning Doc.pptxUnix Trainning Doc.pptx
Unix Trainning Doc.pptxKalpeshRaut7
 
Introduction to Command Line & Batch files
Introduction to Command Line& Batch filesIntroduction to Command Line& Batch files
Introduction to Command Line & Batch filesHayder F. Shamary
 
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCAAARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCAAaravNayan
 
VIM for (PHP) Programmers
VIM for (PHP) ProgrammersVIM for (PHP) Programmers
VIM for (PHP) ProgrammersZendCon
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppthazhamina
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationJacobMenke1
 

Similar to Vim and Python (20)

DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foo
 
NYPHP March 2009 Presentation
NYPHP March 2009 PresentationNYPHP March 2009 Presentation
NYPHP March 2009 Presentation
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1Workshop on command line tools - day 1
Workshop on command line tools - day 1
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
 
58518522 study-aix
58518522 study-aix58518522 study-aix
58518522 study-aix
 
List command linux fidora
List command linux fidoraList command linux fidora
List command linux fidora
 
Terminal linux commands_ Fedora based
Terminal  linux commands_ Fedora basedTerminal  linux commands_ Fedora based
Terminal linux commands_ Fedora based
 
Rhel2
Rhel2Rhel2
Rhel2
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
CMake Tutorial
CMake TutorialCMake Tutorial
CMake Tutorial
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Unix Trainning Doc.pptx
Unix Trainning Doc.pptxUnix Trainning Doc.pptx
Unix Trainning Doc.pptx
 
Introduction to Command Line & Batch files
Introduction to Command Line& Batch filesIntroduction to Command Line& Batch files
Introduction to Command Line & Batch files
 
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCAAARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
 
VIM for (PHP) Programmers
VIM for (PHP) ProgrammersVIM for (PHP) Programmers
VIM for (PHP) Programmers
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 

Recently uploaded

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

Vim and Python

  • 1. VIM and Python - Tips and Tricks http://xkcd.com/378/
  • 2. Getting Around h/j/k/l gg and G – start/end of buffer ^ - first non-blank character in current line $ - last character on current line CTRL-u / CTRL-d – page up / page down :n – go to line number n. H/M/L – go to first/middle/last line on screen* % - jump to corresponding bracket [] {} ()
  • 3. Marks m followed by a letter to set a mark ` followed by the letter – jump to that mark :marks will list current marks Vim has some special marks (a few examples): `. - jump to position where the last change occured `` - jump back to position where you jumped from lots more found in :help `
  • 4. Making Changes y/d/c – yank/delete/change Y/D/C – same as above, but specifies line* p/P – paste before/after combine with movements: dw – delete word cw – change word dG – delete from cursor to end of file c`a – change from cursor to mark a
  • 5. Making Changes y/d/c – yank/delete/change Y/D/C – same as above, but specifies line* p/P – paste after/before x/r – delete/replace single character combine with movements: dw – delete word cw – change word dG – delete from cursor to end of file c`a – change from cursor to mark a use the . character to repeat last command
  • 6. Visual Mode v – enter visual mode V – enter visual mode, but operate on a line CTRL-v -enter visual mode, operate on a column Use I to change all columns at once combine with y/d/c for even more fun
  • 7. Text Objects used after an operator or visual mode i – inner / a – ambient a' / i' – operate on block of '' a( / i( - operate of block of () a{ / i{ - operate of block of {} at / it – operate of html or xml tags
  • 8. Search / or ? - for a basic search (forward or backward) I recommend :set ignore case, :set smartcase and :set incsearch n to repeat search, or N to repeat in opposite direction */# - find next/previous of word under cursor [I – list lines with word under cursor set up a map to make this easier: :map <space>f [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[t"<CR>
  • 9. Undos u – undo, CTRL-R – redo see also: undo-branches time travel :earlier Ns, m, h :later Ns,m,h Can't jump to the future when the code is already done, sorry. Hoping for that feature in Vim 8
  • 10. Splitting Windows :sp -horizontal split :vs – vertical split :new CTRL-w + movement to move between windows I remap spacebar for easier commands
  • 11. Configuration .vimrc – global settings .vim directory - plugins, color schemes, syntax definitions, etc browse github for ideas, or just fork one you like :set – see your current settings don't be afraid to consult :help to see what things do
  • 12. Config Examples filtype plugin on – recoginize .py as python filtype indent on – proper indentation (more on this later) set nu – turn line numbers on set ruler – see where you are in the file set t_Co=256 – 256 colors cmap w!! %!sudo tee > /dev/null % made changes to a read-only file? This mapping allows you to use :w!! to save using sudo
  • 13. More Config Examples au BufReadPost * if line("'"") > 0 && line("'"") <= line("$")|execute("normal `"")|endif jumps cursor to last edited position on file open set pastetoggle=<F10> easy way to shift to paste mode to not screw up indentation nmap <silent> <F6> :set number!<CR> turn line numbers on/off set iskeyword-=- use dash as a word seperator
  • 14. Indentation My biggest hang-up when I started with python Found a python indent file that works pretty well Found in .vim/after/indent/ Autoindents/unindents around keywords Various other indent definitions available (djangohtml is another I use) = command will re-indent use > and < to indent keys
  • 15. Autocomplete <tab> invokes autocomplete Use options wildmode and wildmenu to change how this works (I use list:longest,full) Also work on filenames/directories (:e <tab>) There are other forms of autocomplete: Omnicomplete – Heuristics based completion, I haven't had much luck pydiction plugin – keyword/modules
  • 16. tags I map F4 to rebuild tags file using ctags CTRL-] - jump to tag under cursor CTRL-T – return to where you came from :tag <tagname> - jump to a tag If there are multiple matches, you select from a list taglist is another useful plugin to view the tags in the current file
  • 17. NERDtree Popular file explorer Opens in a new window, which can be re-sized and customised Supports bookmarks I prefer to just use :e + <tab>
  • 18. SelectBuf Similar to a file explorer, but limited to buffers already open A must-have if you normally operate many buffers at once
  • 19. flake-8 wrapper for flake8 (must install seperately) PyFlakes PEP8 complexity checker Can configure to ignore errors I map to F5, as I also use makeprg for other languages using the same key
  • 20. Doxygen Generate comment skeletons :DoxLic - License :DoxAuth - Author :Dox - function/class block headers Works well out of the box, but config options available
  • 21. Other Plugins to Check Out vimpdb commandT project vcscommand OScan snippets netrw scratch