際際滷

際際滷Share a Scribd company logo
Introduction
         Getting started with vim
                            Tasks
               Search and replace
                    Con鍖guration




            vim  Vi IMproved, a programmers text editor

                                     Bart Van Loon


                                    31st January 2012




1 / 30                                           Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
          Getting started with vim
                             Tasks
                Search and replace
                     Con鍖guration




         1 Introduction

         2 Getting started with vim
                Introduction
                Starting and quitting
                The cursor
                Editing text

         3 Tasks

         4 Search and replace

         5 Con鍖guration



2 / 30                                  Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
         Getting started with vim
                            Tasks
               Search and replace
                    Con鍖guration

 How it all began: vi
 A part of history


              text editor originally created for UNIX
              old: 鍖rst release in 1976 (Open Source: BSD license)
              but modern: 2009 survey by Linux Journal  vi[m] most
              widely used text editor (36%); second place: gedit (19%)




3 / 30                                           Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
         Getting started with vim
                            Tasks
               Search and replace
                    Con鍖guration

 How it all began: vi
 Modal editor




              vi is a modal editor:
              insert mode: typed text becomes part of the document
              normal mode: keystrokes are interpreted as commands
               i in normal mode: switch to insert mode; i again at this
              point: place an i character in the document
               esc in insert mode: switch to normal mode
              advantage: both text editing and command operations
              without requiring removal of hands from the home row
               speed!



4 / 30                                        Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
          Getting started with vim
                             Tasks
                Search and replace
                     Con鍖guration

 How it all began: vi
 It breaks my 鍖ngers!


         Many ideas, shortcuts, keystrokes, . . . can be explained by looking
         at a common computer keyboard from the seventies.




5 / 30                                           Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
         Getting started with vim
                            Tasks
               Search and replace
                    Con鍖guration

 How it all began: vi
 Contemporary derivatives and clones




                      vi: traditional vi ported to modern systems
                   vim: (Vi IMproved) vi with many more features
               elvis: once popular clone with some extra features
                   nvi: default derivative shipped with all BSDs
                 vile: attempt to mix emacs and vi
                     ...




6 / 30                                            Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                    Introduction
         Getting started with vim
                                    Starting and quitting
                            Tasks
                                    The cursor
               Search and replace
                                    Editing text
                    Con鍖guration

 vim
 Introduction




              鍖rst released publicly in 1991 (Open Source charityware)
              still actively developed and maintained
              cross platform
              additional features speci鍖cally designed for editing source code
              customisable through plugins and vimscript
              described as very much compatible with vi, but not 100%
              huge community constantly at war with the emacs-community




7 / 30                                                      Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                     Introduction
          Getting started with vim
                                     Starting and quitting
                             Tasks
                                     The cursor
                Search and replace
                                     Editing text
                     Con鍖guration

 vim
 Sooooooo many features

         completion, comparison and merging of 鍖les, comprehensive integrated
         help system, extended regular expressions, scripting languages (both
         native and through alternative scripting interpreters such as Perl, Python,
         Ruby, Tcl, etc. . . ) including support for plugins, a graphical user
         interface, limited integrated development environment-like features,
         mouse interaction (both with and without the GUI), folding, editing of
         compressed or archived 鍖les in gzip, bzip2, zip, and tar format and 鍖les
         over network protocols such as SSH, FTP, and HTTP, session state
         preservation, spell checking, split (horizontal and vertical) and tabbed
         windows, unicode and other multi-language support, syntax highlighting,
         trans-session command, search and cursor position histories, multiple
         level undo/redo history which can persist across editing sessions, visual
         mode, . . .

8 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                     Introduction
          Getting started with vim
                                     Starting and quitting
                             Tasks
                                     The cursor
                Search and replace
                                     Editing text
                     Con鍖guration

 Getting started


         Starting vim
               vim; or
               vim <filename>; or
               vim [options] <filename>



         One useful option is +<n>, which opens the 鍖le and immediately
         puts the cursor on line <n>.




9 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Getting started


          Modes
                by default you start in normal mode
                go to insert mode from normal mode
                        type i to start entering text at the cursor
                        type R to start replacing text at the cursor
                        type o to open a new line at the cursor
                        type O to open a new line above the cursor
                hit esc to enter normal mode




10 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Getting started


          Exiting vim
                commands to quit:
                   : x  : save and quit
                   : q  : just quit
                 : q !  : force quit (without saving!)
                shortcut from normal mode:
                       Z Z : quit and save only if changes were made




11 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Moving the cursor

          Relative movements:
                         h : one character left
                         j : one line down
                         k : one line up
                         l : one character right
                         w : one word forward
                         b : one word back

          Adding a digit multiplies the movement. Try 5 w , 1 2 k ,
          2 b , ...

12 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Moving the cursor


          Absolute movements in the 鍖le:
               ^ or 0 : beginning of the line
                         $ : end of the line
                     g g : beginning of the 鍖le
                         G : end of the 鍖le
               <d> G : line <d>
                     ` . : your last edit




13 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Moving the cursor



          Absolute movements in the screen (visible area):
                         H : highest line on the screen
                         M : middle line on the screen
                         L : lowest line on the screen
               ctrl-f : page (screen) forward
               ctrl-b : page (screen) backward




14 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Editing text


          Inserting text:
                         i : insert text at the cursor
                         a : insert text after the cursor (append)
                         I : insert text at the beginning of the line
                         A : insert text at the end of the line


          In insert mode, you can use the arrow keys to navigate the cursor,
          but often going back to normal mode will be much faster.



15 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Editing text


          Deleting text:
                         x : delete character at the cursor (delete)
                         X : delete character before the cursor (backspace)



          Replacing text:
               r <c> : replace the current character with <c>




16 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Visual mode




          For selecting areas of text, there is visual mode:
                         v : start visual mode
                         V : start visual line mode
               ctrl-v : start visual block mode




17 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Operators and motions

          Example operators:
                         d : delete
                         y : yank (copy)
                         c : change

          Example motions1 :
                         $ : to end of line
                         G : to end of 鍖le
                         e : to end of current word

             1
                 remember the part on moving your cursor?
18 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Combining operators and motions


          Combining operators and motions generates some really powerful
          commands. Some examples are:
                     y $ : copy from the cursor until the end of the line
                d g g : delete from the cursor until the beginning of the 鍖le


          Now lets add counts to increase the power:
                y 3 k : copy the previous 3 lines
                d 5 w : delete the next 5 words



19 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 More power


          Another nice operator:
                         = : 鍖x indenting


          Some other nice motions:
                         ( : to the beginning of the current sentence
                         ) : to the beginning of the next sentence
                         % : to the matching bracket, parenthesis, braces, . . .




20 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 Double operators



          When entering an operator twice, it operates on the complete
          current line:
                     d d : delete the current line
                     y y : copy the current line
                       ...




21 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
                                      Introduction
           Getting started with vim
                                      Starting and quitting
                              Tasks
                                      The cursor
                 Search and replace
                                      Editing text
                      Con鍖guration

 The put command


          To paste previously deleted or yanked (copied) text:
                         p : put (paste) after the cursor
                         P : put (paste) before the cursor


          Some nice usage examples:
                     x p : swap the current character with the next one
                d d p : swap the current line with the next one
                     5 p : paste 5 times after the cursor



22 / 30                                                       Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
           Getting started with vim
                              Tasks
                 Search and replace
                      Con鍖guration

 Repeating tasks


          Undo and redo:


          You can think of each command (combined or not) as a task.
                         . : repeat last task
                         u : undo last task
               ctrl-r : undo last undo (redo)


          Typing text is also a task!



23 / 30                                         Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
           Getting started with vim
                              Tasks
                 Search and replace
                      Con鍖guration

 Macros




          A group of tasks can be recorded as a macro:
               q <a> : start recording macro with name <a>
                         q : stop recording current macro
               @ <a> : replay macro with name <a>




24 / 30                                            Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
           Getting started with vim
                              Tasks
                 Search and replace
                      Con鍖guration

 Search


          To start:
          / <p>  : forward search for <p>
          ? <p>  : backward search for <p>


          Afterwards:
                         n : repeat previous search
                         N : repeat previous search in opposite direction




25 / 30                                               Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
           Getting started with vim
                              Tasks
                 Search and replace
                      Con鍖guration

 Search and replace


          Structure of the command:

                                         :As/B/C/D

          with:
                          A : area on which to operate
                          B : the pattern to search for (regular expression)
                          C : the new word to replace the found pattern with
                          D : any 鍖ags to 鍖ne tune the behaviour




26 / 30                                               Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
           Getting started with vim
                              Tasks
                 Search and replace
                      Con鍖guration

 Search and replace

          Examples areas:
                          % : the complete 鍖le
                   <,> : the selected area
               (empty) : the current line


          Example 鍖ags:
                           c : con鍖rm each substitution
                           g : replace all occurrences on one line
                            i : ignore the case for searching



27 / 30                                                 Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
          Getting started with vim
                             Tasks
                Search and replace
                     Con鍖guration

 ~/.vim*




               your con鍖guration is stored in ~/.vimrc
               system-wide con鍖guration is stored in /etc/vimrc
               your plugins, languages, . . . live in ~/.vim/




28 / 30                                            Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
           Getting started with vim
                              Tasks
                 Search and replace
                      Con鍖guration

 The set-command

          To change your con鍖guration at runtime, use the set-command.
          Examples:
                :set spell to enable spell checking
                :set number show line numbers
                :set syntax=<lang> to highlight according to <lang>

          To unset an option, prepend it with no:
                :set nospell
                :set nonumber
                ...


29 / 30                                         Bart Van Loon   vim  Vi IMproved, a programmers tex
Introduction
          Getting started with vim
                             Tasks
                Search and replace
                     Con鍖guration

 References



               the vimtutor-command
               http://en.wikipedia.org/wiki/Vi
               http://en.wikipedia.org/wiki/Vim_(text_editor)
               https://users.cs.jmu.edu/bernstdh/web/common/
               help/vim.php
               http://www.youtube.com/watch?v=SI8TeVMX8pk
               http://www.youtube.com/watch?v=V3ccIf-cfnQ




30 / 30                                   Bart Van Loon   vim  Vi IMproved, a programmers tex
Ad

Recommended

The Perfect Pitch - stage edition
The Perfect Pitch - stage edition
Bart Van Loon
A future for IT professionals (?)
A future for IT professionals (?)
Bart Van Loon
Mission, Vision and Strategy in organisations
Mission, Vision and Strategy in organisations
Bart Van Loon
Augusta Linux User Group - Vim Introduction
Augusta Linux User Group - Vim Introduction
Keith Pickett
Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)
MohsinHusenManasiya
lectuer 21-22.pptx
lectuer 21-22.pptx
poonam256394
Unit 5 vim an advanced text editor
Unit 5 vim an advanced text editor
root_fibo
Introduction to Vim
Introduction to Vim
Brandon Liu
Vi editor
Vi editor
ParikshitTaksande1
Vi and redirection & piping in linux
Vi and redirection & piping in linux
Neethu Jose
What is Vim?
What is Vim?
Tatiana Tylosky
Linux programming - Getting self started
Linux programming - Getting self started
Emertxe Information Technologies Pvt Ltd
Programming With WinRT And Windows8
Programming With WinRT And Windows8
Rainer Stropek
Open Source Virtualization Hacks
Open Source Virtualization Hacks
Niel Bornstein
The Perfect Pitch - networking edition
The Perfect Pitch - networking edition
Bart Van Loon
Getting started with Imagemagick
Getting started with Imagemagick
Bart Van Loon
Command line essentials
Command line essentials
Bart Van Loon
Met het hoofd online, maar met de voeten in de Vlaamse klei?
Met het hoofd online, maar met de voeten in de Vlaamse klei?
Bart Van Loon
Why study Computer Science?
Why study Computer Science?
Bart Van Loon
The Entrepreneurial Engineer
The Entrepreneurial Engineer
Bart Van Loon
Cultural Learnings of Pakistan for Make Benefit Glorious Nation of Belgium
Cultural Learnings of Pakistan for Make Benefit Glorious Nation of Belgium
Bart Van Loon
Open Source in your company
Open Source in your company
Bart Van Loon
The DataTank
The DataTank
Bart Van Loon
General introduction to Open Source
General introduction to Open Source
Bart Van Loon
DataTank - alpha
DataTank - alpha
Bart Van Loon
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software

More Related Content

Similar to Vi IMproved, a programmers text editor (6)

Vi editor
Vi editor
ParikshitTaksande1
Vi and redirection & piping in linux
Vi and redirection & piping in linux
Neethu Jose
What is Vim?
What is Vim?
Tatiana Tylosky
Linux programming - Getting self started
Linux programming - Getting self started
Emertxe Information Technologies Pvt Ltd
Programming With WinRT And Windows8
Programming With WinRT And Windows8
Rainer Stropek
Open Source Virtualization Hacks
Open Source Virtualization Hacks
Niel Bornstein

More from Bart Van Loon (11)

The Perfect Pitch - networking edition
The Perfect Pitch - networking edition
Bart Van Loon
Getting started with Imagemagick
Getting started with Imagemagick
Bart Van Loon
Command line essentials
Command line essentials
Bart Van Loon
Met het hoofd online, maar met de voeten in de Vlaamse klei?
Met het hoofd online, maar met de voeten in de Vlaamse klei?
Bart Van Loon
Why study Computer Science?
Why study Computer Science?
Bart Van Loon
The Entrepreneurial Engineer
The Entrepreneurial Engineer
Bart Van Loon
Cultural Learnings of Pakistan for Make Benefit Glorious Nation of Belgium
Cultural Learnings of Pakistan for Make Benefit Glorious Nation of Belgium
Bart Van Loon
Open Source in your company
Open Source in your company
Bart Van Loon
The DataTank
The DataTank
Bart Van Loon
General introduction to Open Source
General introduction to Open Source
Bart Van Loon
DataTank - alpha
DataTank - alpha
Bart Van Loon
The Perfect Pitch - networking edition
The Perfect Pitch - networking edition
Bart Van Loon
Getting started with Imagemagick
Getting started with Imagemagick
Bart Van Loon
Command line essentials
Command line essentials
Bart Van Loon
Met het hoofd online, maar met de voeten in de Vlaamse klei?
Met het hoofd online, maar met de voeten in de Vlaamse klei?
Bart Van Loon
Why study Computer Science?
Why study Computer Science?
Bart Van Loon
The Entrepreneurial Engineer
The Entrepreneurial Engineer
Bart Van Loon
Cultural Learnings of Pakistan for Make Benefit Glorious Nation of Belgium
Cultural Learnings of Pakistan for Make Benefit Glorious Nation of Belgium
Bart Van Loon
Open Source in your company
Open Source in your company
Bart Van Loon
General introduction to Open Source
General introduction to Open Source
Bart Van Loon
Ad

Recently uploaded (20)

The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
Down the Rabbit Hole Solving 5 Training Roadblocks
Down the Rabbit Hole Solving 5 Training Roadblocks
Rustici Software
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
June Patch Tuesday
June Patch Tuesday
Ivanti
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
Down the Rabbit Hole Solving 5 Training Roadblocks
Down the Rabbit Hole Solving 5 Training Roadblocks
Rustici Software
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
June Patch Tuesday
June Patch Tuesday
Ivanti
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
Ad

Vi IMproved, a programmers text editor

  • 1. Introduction Getting started with vim Tasks Search and replace Con鍖guration vim Vi IMproved, a programmers text editor Bart Van Loon 31st January 2012 1 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 2. Introduction Getting started with vim Tasks Search and replace Con鍖guration 1 Introduction 2 Getting started with vim Introduction Starting and quitting The cursor Editing text 3 Tasks 4 Search and replace 5 Con鍖guration 2 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 3. Introduction Getting started with vim Tasks Search and replace Con鍖guration How it all began: vi A part of history text editor originally created for UNIX old: 鍖rst release in 1976 (Open Source: BSD license) but modern: 2009 survey by Linux Journal vi[m] most widely used text editor (36%); second place: gedit (19%) 3 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 4. Introduction Getting started with vim Tasks Search and replace Con鍖guration How it all began: vi Modal editor vi is a modal editor: insert mode: typed text becomes part of the document normal mode: keystrokes are interpreted as commands i in normal mode: switch to insert mode; i again at this point: place an i character in the document esc in insert mode: switch to normal mode advantage: both text editing and command operations without requiring removal of hands from the home row speed! 4 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 5. Introduction Getting started with vim Tasks Search and replace Con鍖guration How it all began: vi It breaks my 鍖ngers! Many ideas, shortcuts, keystrokes, . . . can be explained by looking at a common computer keyboard from the seventies. 5 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 6. Introduction Getting started with vim Tasks Search and replace Con鍖guration How it all began: vi Contemporary derivatives and clones vi: traditional vi ported to modern systems vim: (Vi IMproved) vi with many more features elvis: once popular clone with some extra features nvi: default derivative shipped with all BSDs vile: attempt to mix emacs and vi ... 6 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 7. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration vim Introduction 鍖rst released publicly in 1991 (Open Source charityware) still actively developed and maintained cross platform additional features speci鍖cally designed for editing source code customisable through plugins and vimscript described as very much compatible with vi, but not 100% huge community constantly at war with the emacs-community 7 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 8. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration vim Sooooooo many features completion, comparison and merging of 鍖les, comprehensive integrated help system, extended regular expressions, scripting languages (both native and through alternative scripting interpreters such as Perl, Python, Ruby, Tcl, etc. . . ) including support for plugins, a graphical user interface, limited integrated development environment-like features, mouse interaction (both with and without the GUI), folding, editing of compressed or archived 鍖les in gzip, bzip2, zip, and tar format and 鍖les over network protocols such as SSH, FTP, and HTTP, session state preservation, spell checking, split (horizontal and vertical) and tabbed windows, unicode and other multi-language support, syntax highlighting, trans-session command, search and cursor position histories, multiple level undo/redo history which can persist across editing sessions, visual mode, . . . 8 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 9. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Getting started Starting vim vim; or vim <filename>; or vim [options] <filename> One useful option is +<n>, which opens the 鍖le and immediately puts the cursor on line <n>. 9 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 10. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Getting started Modes by default you start in normal mode go to insert mode from normal mode type i to start entering text at the cursor type R to start replacing text at the cursor type o to open a new line at the cursor type O to open a new line above the cursor hit esc to enter normal mode 10 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 11. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Getting started Exiting vim commands to quit: : x : save and quit : q : just quit : q ! : force quit (without saving!) shortcut from normal mode: Z Z : quit and save only if changes were made 11 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 12. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Moving the cursor Relative movements: h : one character left j : one line down k : one line up l : one character right w : one word forward b : one word back Adding a digit multiplies the movement. Try 5 w , 1 2 k , 2 b , ... 12 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 13. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Moving the cursor Absolute movements in the 鍖le: ^ or 0 : beginning of the line $ : end of the line g g : beginning of the 鍖le G : end of the 鍖le <d> G : line <d> ` . : your last edit 13 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 14. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Moving the cursor Absolute movements in the screen (visible area): H : highest line on the screen M : middle line on the screen L : lowest line on the screen ctrl-f : page (screen) forward ctrl-b : page (screen) backward 14 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 15. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Editing text Inserting text: i : insert text at the cursor a : insert text after the cursor (append) I : insert text at the beginning of the line A : insert text at the end of the line In insert mode, you can use the arrow keys to navigate the cursor, but often going back to normal mode will be much faster. 15 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 16. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Editing text Deleting text: x : delete character at the cursor (delete) X : delete character before the cursor (backspace) Replacing text: r <c> : replace the current character with <c> 16 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 17. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Visual mode For selecting areas of text, there is visual mode: v : start visual mode V : start visual line mode ctrl-v : start visual block mode 17 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 18. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Operators and motions Example operators: d : delete y : yank (copy) c : change Example motions1 : $ : to end of line G : to end of 鍖le e : to end of current word 1 remember the part on moving your cursor? 18 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 19. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Combining operators and motions Combining operators and motions generates some really powerful commands. Some examples are: y $ : copy from the cursor until the end of the line d g g : delete from the cursor until the beginning of the 鍖le Now lets add counts to increase the power: y 3 k : copy the previous 3 lines d 5 w : delete the next 5 words 19 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 20. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration More power Another nice operator: = : 鍖x indenting Some other nice motions: ( : to the beginning of the current sentence ) : to the beginning of the next sentence % : to the matching bracket, parenthesis, braces, . . . 20 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 21. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration Double operators When entering an operator twice, it operates on the complete current line: d d : delete the current line y y : copy the current line ... 21 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 22. Introduction Introduction Getting started with vim Starting and quitting Tasks The cursor Search and replace Editing text Con鍖guration The put command To paste previously deleted or yanked (copied) text: p : put (paste) after the cursor P : put (paste) before the cursor Some nice usage examples: x p : swap the current character with the next one d d p : swap the current line with the next one 5 p : paste 5 times after the cursor 22 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 23. Introduction Getting started with vim Tasks Search and replace Con鍖guration Repeating tasks Undo and redo: You can think of each command (combined or not) as a task. . : repeat last task u : undo last task ctrl-r : undo last undo (redo) Typing text is also a task! 23 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 24. Introduction Getting started with vim Tasks Search and replace Con鍖guration Macros A group of tasks can be recorded as a macro: q <a> : start recording macro with name <a> q : stop recording current macro @ <a> : replay macro with name <a> 24 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 25. Introduction Getting started with vim Tasks Search and replace Con鍖guration Search To start: / <p> : forward search for <p> ? <p> : backward search for <p> Afterwards: n : repeat previous search N : repeat previous search in opposite direction 25 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 26. Introduction Getting started with vim Tasks Search and replace Con鍖guration Search and replace Structure of the command: :As/B/C/D with: A : area on which to operate B : the pattern to search for (regular expression) C : the new word to replace the found pattern with D : any 鍖ags to 鍖ne tune the behaviour 26 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 27. Introduction Getting started with vim Tasks Search and replace Con鍖guration Search and replace Examples areas: % : the complete 鍖le <,> : the selected area (empty) : the current line Example 鍖ags: c : con鍖rm each substitution g : replace all occurrences on one line i : ignore the case for searching 27 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 28. Introduction Getting started with vim Tasks Search and replace Con鍖guration ~/.vim* your con鍖guration is stored in ~/.vimrc system-wide con鍖guration is stored in /etc/vimrc your plugins, languages, . . . live in ~/.vim/ 28 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 29. Introduction Getting started with vim Tasks Search and replace Con鍖guration The set-command To change your con鍖guration at runtime, use the set-command. Examples: :set spell to enable spell checking :set number show line numbers :set syntax=<lang> to highlight according to <lang> To unset an option, prepend it with no: :set nospell :set nonumber ... 29 / 30 Bart Van Loon vim Vi IMproved, a programmers tex
  • 30. Introduction Getting started with vim Tasks Search and replace Con鍖guration References the vimtutor-command http://en.wikipedia.org/wiki/Vi http://en.wikipedia.org/wiki/Vim_(text_editor) https://users.cs.jmu.edu/bernstdh/web/common/ help/vim.php http://www.youtube.com/watch?v=SI8TeVMX8pk http://www.youtube.com/watch?v=V3ccIf-cfnQ 30 / 30 Bart Van Loon vim Vi IMproved, a programmers tex