Vimperl

25
Eective Text Editing for Perl Developers Ynon Perek [email protected]

description

My talk at telaviv.pm meetup on May 28

Transcript of Vimperl

Page 1: Vimperl

Effective Text Editing for Perl Developers

Ynon Perek [email protected]

Page 2: Vimperl

Agenda

What’s Wrong with my editor?

Can you fix it?

Should I Switch Editors?

Page 3: Vimperl

! text editors slow you down

Keynote Template

Page 4: Vimperl

Reasons to be angry

• A text editor always slows you down

• Some are worse than others

Page 5: Vimperl

type less,

Keynote Template

more"

Page 6: Vimperl

Some annoyances with “naive” text editors

• Writing code

• Navigating in code

• Testing code

• Running code

Page 7: Vimperl

1 while(<>) {! 2 ! 3 }! 4 ! 5 sub doStuff {! 6 ! 7 }! 8 ! 9 for ( my $i=0; $i < 10; $i++ ) {!10 !11 }

Code is written in sentences, not characters

Page 8: Vimperl

Code uses boilerplates

1 package BlogPost;!2 use Moose;!3 use v5.18;!4 !5 !6 1;

1 <!DOCTYPE html>! 2 <html>! 3 <head>! 4 <meta charset="utf-8" />! 5 <title>test</title>! 6 </head>! 7 <body>! 8 ! 9 </body>!10 </html>

Page 9: Vimperl

Code has context

1 use strict;!2 use warnings;!3 use List::MoreUtils qw/pairwise/;!4 use v5.18;!5 !6 my @foo, @bar;!7 my %h = pairwise(@foo, @bar);

you’ll probably want @foo or @bar here

Page 10: Vimperl

Code can be repetitive

1 my $mail = {!2 john => '[email protected]',!3 bob => '[email protected]',!4 barbara => '[email protected]',!5 george => '[email protected]',!6 };!7 !

1 my $mail = {!2 john => '[email protected]',!3 bob => '[email protected]',!4 barbara => '[email protected]',!5 george => '[email protected]',!6 };!7 !

Page 11: Vimperl

The more you type…

• you’ll waste more time

• you’ll make more mistakes

• you’ll be less happy

Page 12: Vimperl

A text editor can be a friend

• In writing:

• Code snippets

• File templates

• Context aware auto complete

• Verify syntax and find errors early

Page 13: Vimperl

A text editor can be a friend

• While working on a project:

• File navigation

• Documentation

• Quickly find what you need

Page 14: Vimperl

A text editor can be a friend

• While running and testing:

• Reminds you to run unit tests

• Helps you run complex flows

Page 15: Vimperl

Agenda

What’s Wrong with my editor?

Can you fix it?

Should I Switch Editors?

Page 16: Vimperl

Fixing a text editor• File templates

• Code snippets

• Omni complete

• Easy project navigation + documentation

• Running + testing

Page 17: Vimperl

We’ll use …

# janus

A fully customisable text editor

A collection of plugins and settings for vim to get started

+

Page 18: Vimperl

Getting Started (Ubuntu)

sudo apt-get install vim-gnome

Install vim

curl -Lo- https://bit.ly/janus-bootstrap | bash

Install janus

Page 19: Vimperl

What We Got

• Line and column numbers

• Nicer colours and better defaults

Page 20: Vimperl

What We Got• Find in files - ack

• Fuzzy file finder

• Easy code comments

• Project drawer

• Tab completion

• Basic snippets

Page 21: Vimperl

Now let’s get to work

Page 22: Vimperl

Demos - Editing• Adding new snippets with snipMate

• File templates with vim-template

• Align perl hashes

• Perl omni-complete

• Auto-close parens

Page 23: Vimperl

Plugins Installed• Viewdoc:

http://www.vim.org/scripts/script.php?script_id=3893

• Vim template:https://github.com/aperezdc/vim-template/

• Auto pairs:https://github.com/ynonp/auto-pairs

Page 24: Vimperl

Q & A

Page 25: Vimperl

Thanks For Listening

• Ynon Perek

• http://ynonperek.com/

[email protected]