SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
How to vim
author: Marcin Rogacki <mrogacki@nexway.com>, <rogacki.m@gmail.com>
experience in vim: 6 months
Why try?
1. Successfully used as IDE by others.
2. Don’t need X enviroment (Production quick fix? No problem!)
3. Lightweight & fast.
4. Able to edit large files 50MB, 100MB, 1GB (Ok... search the 1GB file is
an horror but still is openable).
5. Code is written faster (with enough vim experience).
6. Your keyboard skills will be improved.
place of new recruits is to the proving ground
run shell command: vimtutor
training
Now time for ‘Missions’.
They show practical tricks (at least I have hope
that they are practical) or just examples how to
fight with vim.
Basics
● move: hjklweb$0gGf
● edit: aiorxdvc
● search: /nf
● undo and redo: u, ctrl+r
● copy & paste: ypdx
combine all of above into “advanced basics”
don’t use arrows or mouse!
Armory
output
input
Mission: delete from here to end
Accomplished: d,shift + g
line no. 1
line no. 2
line no. 3
line no. 4
line no. 5
line no. 1
line no. 2
output
input
Mission: delete from here to line 4
Accomplished: d,4,shift+g
line no. 1
line no. 2
line no. 3
line no. 4
line no. 5
line no. 1
line no. 5
output
input
Mission: copy & paste - line
Accomplished: yy,j,p
line no. 1
line no. 2
line no. 3
line no. 4
line no. 5
line no. 1
line no. 2
line no. 3
line no. 4
line no. 3
line no. 5
outputinput
Mission: cut & paste - text refactoring
Accomplished: v,w,d,p
$product->setName(‘Not so very long name’);
$name = ‘Not so very long name’;
$product->setName($name);
outputinput
Mission: cut & paste - text refactoring v2
Accomplished: v,f,’,d,p
$product->setName(‘Not so very long name’);
$name = ‘Not so very long name’;
$product->setName($name);
outputinput
Mission: cut & paste - text refactoring v3
Accomplished: d,f,’,p
$product->setName(‘Not so very long name’);
$name = ‘Not so very long name’;
$product->setName($name);
outputinput
Mission: cut & paste - text refactoring v4
Accomplished: c,f,’,p
$product->setName(‘Not so very long name’);
$name = ‘Not so very long name’;
$product->setName($name);
output
input
Mission: insert column beetwen
Accomplished: ctrl + v, A, ESC, j
$productObj->doSmth();
$productObj->doSmthElse();
$productObj->doAnother();
$productObj->doNothing();
$product->doSmth();
$product->doSmthElse();
$product->doAnother();
$product->doNothing();
output
input
Mission: replace column
Accomplished: ctrl + v, c, ESC, j
$product->doSmth();
$product->doSmthElse();
$product->doAnother();
$product->doNothing();
$item->doSmth();
$item->doSmthElse();
$item->doAnother();
$item->doNothing();
output
input
Mission: add at very last
Accomplished: $, ctrl + v, shift + a, ESC, j
$product->doSmth()
$product->doSmthElse()
$product->doAnother()
$product->doNothing()
$product->doSmth();
$product->doSmthElse();
$product->doAnother();
$product->doNothing();
output
input
Mission: comment out
Accomplished: 0, ctrl + v, I, ESC, j
$product->doSmth();
$product->doSmthElse();
$product->doAnother();
$product->doNothing();
//$product->doSmth();
//$product->doSmthElse();
//$product->doAnother();
//$product->doNothing();
The menu bar & tabs
Armory
:edit <file> - open in current window
:newtab <file> - open new tab
:vsplit <file> - vertical split and open
:split <file> - horizontal split and
:r <file> - read content into current file
:! - execute shell command
:<text> - is a vim command
ctrl + ww - switch tab
gt - next window
output
input
Mission: copy & paste from other file
Accomplished: :r docs/beer-license.txt
License License
THE BEER-WARE LICENSE:
Can do whatever you want.
You can buy me a beer in return.
output
input
Mission: copy & paste shell console
Files list
Accomplished: :r !ls -l
Files list
code/file.php
lib/file.php
public/file.js
output
input
Mission: copy&paste between tabs/windows
Accomplished: g,t,y,y,g,t,p
Some text window 1
Some text window 2
Some text window 1
Some text window 2
Some text window 2
Text manipulations
Armory
/ - search
:s/<search>/<replace>/g - search & replace
ctrl + p - text autocomplete backward
ctrl + n - text autocomplete forward
:<text> - is a vim command
output
input
Mission: Search & replace
Accomplished: :s/product/item/gc
$product->doSmth();
$product->doSmthElse();
$product->doAnother();
$product->doNothing();
$item->doSmth();
$item->doSmthElse();
$item->doAnother();
$item->doNothing();
output
input
Accomplished: ctrl + p or ctrl + n (input mode!)
Mission: autocoplete
$product->doSmth();
$product->doSmthElse();
$product->doAnother();
$product->doS;
$item->doSmth();
$item->doSmthElse();
$item->doAnother();
$item->doSmthElse();
Macros
Armory
q - record macro (in fly!)
small but powerful
how to use macros
1. find some ‘regularities’
2. record macro by q and pick an <register> (e.g. ‘a’ key)
3. work as usual with vim
4. stop recording by q
5. set cursor at next ‘regularity’ <number of repeats>@<register>
output
input
Mission: add ‘irregular’ text
Accomplished: qakf(wyw0jf(pa,ESCF(wctrl+a0jq10@a
Before start ensure that cursor is set at 2-nd line, keys: ggj. Then just invoke this sequence.
INSERT INTO category VALUES(1,'Basics');
INSERT INTO category VALUES('Request');
INSERT INTO category VALUES('Render',);
INSERT INTO category VALUES('EAV');
INSERT INTO category VALUES(‘Admin');
INSERT INTO category VALUES('Catalog');
INSERT INTO category VALUES('Model');
INSERT INTO category VALUES('Helper');
INSERT INTO category VALUES('Config');
INSERT INTO category VALUES('System');
INSERT INTO category VALUES('Shell');
INSERT INTO category VALUES('Db');
INSERT INTO category VALUES(1,'Basics');
INSERT INTO category VALUES(2,'Request');
INSERT INTO category VALUES(3,'Render',);
INSERT INTO category VALUES(4,'EAV');
INSERT INTO category VALUES(5,‘Admin');
INSERT INTO category VALUES(6,'Catalog');
INSERT INTO category VALUES(7,'Model');
INSERT INTO category VALUES(7,'Helper');
INSERT INTO category VALUES(8,'Config');
INSERT INTO category VALUES(9,'System');
INSERT INTO category VALUES(10,'Shell');
INSERT INTO category VALUES(11, 'Db');
Plugins
Armory
vim-pathogen - simplifies installing the plugins
nerdtree - project tree
vim-snipmate - text templates
phpcomplete.vim - code autocomplete support (php)
fuzzyfinder - file searcher (by pattern)
DBGPavim - php debugger
and many more… (google.pl)
Mission: project tree
Accomplished: nerdtree
Mission: text templates
http://www.youtube.com/watch?v=xV2IsE5OHd4
Accomplished: vim-snipmate
Mission: code autocomplete
Accomplished: phpcomplete.vim
Mission: file search
Accomplished: fuzzyfinder
Mission: debug
Accomplished: DBGPavim (not tested)
Last words
1. Vim is not better than other IDE's. It is different. There is advantages
and disadvantages e.g. I think native IDE will alwasy have better code
autocomplete.
2. Before grabbing a mouse, early try do it with keyboard. Power of vim
is: to be always ready for text typing.
3. Beginnings are difficult, but after time will appear the conditioned
response, in the other words copy&paste/movement/refactor will take
milliseconds.
Mission Accomplished

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBIntroduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDB
Adrien Joly
 
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring frameworkAssurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring framework
Gosuke Miyashita
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRb
Juan Maiz
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Gosuke Miyashita
 

Was ist angesagt? (20)

Callbacks and control flow in Node js
Callbacks and control flow in Node jsCallbacks and control flow in Node js
Callbacks and control flow in Node js
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
 
Introduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBIntroduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDB
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
 
Avoiding Callback Hell with Async.js
Avoiding Callback Hell with Async.jsAvoiding Callback Hell with Async.js
Avoiding Callback Hell with Async.js
 
ES6 PPT FOR 2016
ES6 PPT FOR 2016ES6 PPT FOR 2016
ES6 PPT FOR 2016
 
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring frameworkAssurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring framework
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRb
 
What's new in PHP 8.0?
What's new in PHP 8.0?What's new in PHP 8.0?
What's new in PHP 8.0?
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
 
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.
 
ECMAScript 6 and the Node Driver
ECMAScript 6 and the Node DriverECMAScript 6 and the Node Driver
ECMAScript 6 and the Node Driver
 
node ffi
node ffinode ffi
node ffi
 
Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015Code Generation in PHP - PHPConf 2015
Code Generation in PHP - PHPConf 2015
 
The Ring programming language version 1.5.1 book - Part 74 of 180
The Ring programming language version 1.5.1 book - Part 74 of 180The Ring programming language version 1.5.1 book - Part 74 of 180
The Ring programming language version 1.5.1 book - Part 74 of 180
 
Swiftの関数型っぽい部分
Swiftの関数型っぽい部分Swiftの関数型っぽい部分
Swiftの関数型っぽい部分
 
nginx mod PSGI
nginx mod PSGInginx mod PSGI
nginx mod PSGI
 
Python meetup: coroutines, event loops, and non-blocking I/O
Python meetup: coroutines, event loops, and non-blocking I/OPython meetup: coroutines, event loops, and non-blocking I/O
Python meetup: coroutines, event loops, and non-blocking I/O
 

Andere mochten auch

Andere mochten auch (6)

Sap vendor invoice management
Sap vendor invoice managementSap vendor invoice management
Sap vendor invoice management
 
Avaali Solutions - Sap invoice management by open text
Avaali Solutions - Sap invoice management by open textAvaali Solutions - Sap invoice management by open text
Avaali Solutions - Sap invoice management by open text
 
Sap invoice management webinar 2014-03-28
Sap invoice management webinar 2014-03-28Sap invoice management webinar 2014-03-28
Sap invoice management webinar 2014-03-28
 
OCR and Content Management with SAP and Imaging
OCR and Content Management with SAP and ImagingOCR and Content Management with SAP and Imaging
OCR and Content Management with SAP and Imaging
 
Vendor Invoice Management
Vendor Invoice ManagementVendor Invoice Management
Vendor Invoice Management
 
Agile Transformation and Cultural Change
 Agile Transformation and Cultural Change Agile Transformation and Cultural Change
Agile Transformation and Cultural Change
 

Ähnlich wie How to Vim - for beginners

Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Paulo Ragonha
 
Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4
elliando dias
 

Ähnlich wie How to Vim - for beginners (20)

How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.The $path to knowledge: What little it take to unit-test Perl.
The $path to knowledge: What little it take to unit-test Perl.
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?
 
NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016NYU hacknight, april 6, 2016
NYU hacknight, april 6, 2016
 
Functional Javascript
Functional JavascriptFunctional Javascript
Functional Javascript
 
JSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklJSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph Pickl
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
Practical Ext JS Debugging
Practical Ext JS DebuggingPractical Ext JS Debugging
Practical Ext JS Debugging
 
How To Test Everything
How To Test EverythingHow To Test Everything
How To Test Everything
 
Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
ES6 - Next Generation Javascript
ES6 - Next Generation JavascriptES6 - Next Generation Javascript
ES6 - Next Generation Javascript
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
人力
人力人力
人力
 

Kürzlich hochgeladen

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Kürzlich hochgeladen (20)

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

How to Vim - for beginners

  • 1. How to vim author: Marcin Rogacki <mrogacki@nexway.com>, <rogacki.m@gmail.com> experience in vim: 6 months
  • 2. Why try? 1. Successfully used as IDE by others. 2. Don’t need X enviroment (Production quick fix? No problem!) 3. Lightweight & fast. 4. Able to edit large files 50MB, 100MB, 1GB (Ok... search the 1GB file is an horror but still is openable). 5. Code is written faster (with enough vim experience). 6. Your keyboard skills will be improved.
  • 3. place of new recruits is to the proving ground run shell command: vimtutor training
  • 4. Now time for ‘Missions’. They show practical tricks (at least I have hope that they are practical) or just examples how to fight with vim.
  • 6. ● move: hjklweb$0gGf ● edit: aiorxdvc ● search: /nf ● undo and redo: u, ctrl+r ● copy & paste: ypdx combine all of above into “advanced basics” don’t use arrows or mouse! Armory
  • 7. output input Mission: delete from here to end Accomplished: d,shift + g line no. 1 line no. 2 line no. 3 line no. 4 line no. 5 line no. 1 line no. 2
  • 8. output input Mission: delete from here to line 4 Accomplished: d,4,shift+g line no. 1 line no. 2 line no. 3 line no. 4 line no. 5 line no. 1 line no. 5
  • 9. output input Mission: copy & paste - line Accomplished: yy,j,p line no. 1 line no. 2 line no. 3 line no. 4 line no. 5 line no. 1 line no. 2 line no. 3 line no. 4 line no. 3 line no. 5
  • 10. outputinput Mission: cut & paste - text refactoring Accomplished: v,w,d,p $product->setName(‘Not so very long name’); $name = ‘Not so very long name’; $product->setName($name);
  • 11. outputinput Mission: cut & paste - text refactoring v2 Accomplished: v,f,’,d,p $product->setName(‘Not so very long name’); $name = ‘Not so very long name’; $product->setName($name);
  • 12. outputinput Mission: cut & paste - text refactoring v3 Accomplished: d,f,’,p $product->setName(‘Not so very long name’); $name = ‘Not so very long name’; $product->setName($name);
  • 13. outputinput Mission: cut & paste - text refactoring v4 Accomplished: c,f,’,p $product->setName(‘Not so very long name’); $name = ‘Not so very long name’; $product->setName($name);
  • 14. output input Mission: insert column beetwen Accomplished: ctrl + v, A, ESC, j $productObj->doSmth(); $productObj->doSmthElse(); $productObj->doAnother(); $productObj->doNothing(); $product->doSmth(); $product->doSmthElse(); $product->doAnother(); $product->doNothing();
  • 15. output input Mission: replace column Accomplished: ctrl + v, c, ESC, j $product->doSmth(); $product->doSmthElse(); $product->doAnother(); $product->doNothing(); $item->doSmth(); $item->doSmthElse(); $item->doAnother(); $item->doNothing();
  • 16. output input Mission: add at very last Accomplished: $, ctrl + v, shift + a, ESC, j $product->doSmth() $product->doSmthElse() $product->doAnother() $product->doNothing() $product->doSmth(); $product->doSmthElse(); $product->doAnother(); $product->doNothing();
  • 17. output input Mission: comment out Accomplished: 0, ctrl + v, I, ESC, j $product->doSmth(); $product->doSmthElse(); $product->doAnother(); $product->doNothing(); //$product->doSmth(); //$product->doSmthElse(); //$product->doAnother(); //$product->doNothing();
  • 18. The menu bar & tabs
  • 19. Armory :edit <file> - open in current window :newtab <file> - open new tab :vsplit <file> - vertical split and open :split <file> - horizontal split and :r <file> - read content into current file :! - execute shell command :<text> - is a vim command ctrl + ww - switch tab gt - next window
  • 20. output input Mission: copy & paste from other file Accomplished: :r docs/beer-license.txt License License THE BEER-WARE LICENSE: Can do whatever you want. You can buy me a beer in return.
  • 21. output input Mission: copy & paste shell console Files list Accomplished: :r !ls -l Files list code/file.php lib/file.php public/file.js
  • 22. output input Mission: copy&paste between tabs/windows Accomplished: g,t,y,y,g,t,p Some text window 1 Some text window 2 Some text window 1 Some text window 2 Some text window 2
  • 24. Armory / - search :s/<search>/<replace>/g - search & replace ctrl + p - text autocomplete backward ctrl + n - text autocomplete forward :<text> - is a vim command
  • 25. output input Mission: Search & replace Accomplished: :s/product/item/gc $product->doSmth(); $product->doSmthElse(); $product->doAnother(); $product->doNothing(); $item->doSmth(); $item->doSmthElse(); $item->doAnother(); $item->doNothing();
  • 26. output input Accomplished: ctrl + p or ctrl + n (input mode!) Mission: autocoplete $product->doSmth(); $product->doSmthElse(); $product->doAnother(); $product->doS; $item->doSmth(); $item->doSmthElse(); $item->doAnother(); $item->doSmthElse();
  • 28. Armory q - record macro (in fly!) small but powerful
  • 29. how to use macros 1. find some ‘regularities’ 2. record macro by q and pick an <register> (e.g. ‘a’ key) 3. work as usual with vim 4. stop recording by q 5. set cursor at next ‘regularity’ <number of repeats>@<register>
  • 30. output input Mission: add ‘irregular’ text Accomplished: qakf(wyw0jf(pa,ESCF(wctrl+a0jq10@a Before start ensure that cursor is set at 2-nd line, keys: ggj. Then just invoke this sequence. INSERT INTO category VALUES(1,'Basics'); INSERT INTO category VALUES('Request'); INSERT INTO category VALUES('Render',); INSERT INTO category VALUES('EAV'); INSERT INTO category VALUES(‘Admin'); INSERT INTO category VALUES('Catalog'); INSERT INTO category VALUES('Model'); INSERT INTO category VALUES('Helper'); INSERT INTO category VALUES('Config'); INSERT INTO category VALUES('System'); INSERT INTO category VALUES('Shell'); INSERT INTO category VALUES('Db'); INSERT INTO category VALUES(1,'Basics'); INSERT INTO category VALUES(2,'Request'); INSERT INTO category VALUES(3,'Render',); INSERT INTO category VALUES(4,'EAV'); INSERT INTO category VALUES(5,‘Admin'); INSERT INTO category VALUES(6,'Catalog'); INSERT INTO category VALUES(7,'Model'); INSERT INTO category VALUES(7,'Helper'); INSERT INTO category VALUES(8,'Config'); INSERT INTO category VALUES(9,'System'); INSERT INTO category VALUES(10,'Shell'); INSERT INTO category VALUES(11, 'Db');
  • 32. Armory vim-pathogen - simplifies installing the plugins nerdtree - project tree vim-snipmate - text templates phpcomplete.vim - code autocomplete support (php) fuzzyfinder - file searcher (by pattern) DBGPavim - php debugger and many more… (google.pl)
  • 39. 1. Vim is not better than other IDE's. It is different. There is advantages and disadvantages e.g. I think native IDE will alwasy have better code autocomplete. 2. Before grabbing a mouse, early try do it with keyboard. Power of vim is: to be always ready for text typing. 3. Beginnings are difficult, but after time will appear the conditioned response, in the other words copy&paste/movement/refactor will take milliseconds.