SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
RedHat Enterprise Linux Essential
  Unit 5: vim: An Advanced Text Editor
vim: An Advanced Text Editor
   Introducing vim
   vim: A Modal Editor
   vim Basics
   Opening a file in vim
   Modifying a File Insert Mode
   Saving a File and Exiting vim Ex Mode
   Using Command Mode
   Moving Around Command Mode
   Search and Replace Command Mode
   Manipulating Text Command Mode
   Undoing Changes Command Mode
   Visual Mode
   Using multiple "windows“
   Configuring vi and vim
   Learning more
Introducing vim
 Newer version of vi, the standard Unix text editor
     Executing vi runs vim by default
 gvim: Graphical version of vim
     Applications + Programming -> Vi iMproved
     Provided by vim-X11 package
 Advantages:
    Speed: Do more with fewer keystrokes
    Simplicity: No dependence on mouse/GUI
    Availability: Included with most Unix-like OSes
 Disadvantages
    Difficulty: Steeper learning curve than simpler editors
        • Key bindings emphasize speed over intuitiveness
vim Basics

 To use vim, you must at least be able to
    Open a file

    Modify a file (insert mode)

    Save a file (ex mode)
Opening a file in vim


 To start vi:

    vim filename

    If the file exists, the file is opened and the contents are displayed

    If the file does not exist, vi creates it when the edits are saved for the

     first time
Modifying a File Insert Mode

 i begins insert mode at the cursor

 Many other options exist
    A append to end of line

    I insert at beginning of line

    o insert new a line (below)

    O insert new line (above)
Saving a File and Exiting vim Ex Mode


 Enter Ex Mode with :
    Creates a command prompt at bottom-left of screen

 Common write/quit commands:
    :w writes (saves) the file to disk

    :wq writes and quits

    :q! quits, even if changes are lost
Using Command Mode


 Default mode of vim

 Keys describe movement and text manipulation commands

 Commands repeat when preceded by a number

 Example
    Right Arrow moves right one character

    5, Right Arrow moves right five characters
Moving Around Command Mode

 Move by character: Arrow Keys, h, j, k, l
    Non-arrow keys useful for remote connections to older systems

 Move by word: w, b

 Move by sentence: ), (

 Move by paragraph: }, {

 Jump to line x: xG

 Jump to end: G
Search and Replace Command Mode

 Search as in less
    /, n, N

 Search/Replace as in sed
    Affects current line by default

    Use x,y ranges or % for whole file

               :1,5s/cat/dog/

               :%s/cat/dog/gi
Manipulating Text Command Mode
Undoing Changes Command Mode


 u undo most recent change

 U undo all changes to the current line since the cursor landed
  on the line

 Ctrl-r redo last "undone" change
Visual Mode


 Allows selection of blocks of text
    v starts character-oriented highlighting

    V starts line-oriented highlighting

    Activated with mouse in gvim

 Visual keys can be used in conjunction with movement keys:
    w, ), }, arrows, etc

 Highlighted text can be deleted, yanked, changed, filtered,
  search/replaced, etc.
Using multiple "windows"


 Multiple documents can be viewed in a single vim screen.

       $ vim –o ~/.bashrc ~/.bash_profile
    Ctrl-w, s splits the screen horizontally

    Ctrl-w, v splits the screen vertically

    Ctrl-w, Arrow moves between windows

 Ex-mode instructions always affect the current window

 :help windows displays more window commands
Configuring vi and vim
 Configuring on the fly
                :set or :set all
 Configuring permanently
                ~/.vimrc or ~/.exrc
 A few common configuration items
      :set number
      :set autoindent
      :set textwidth=65 (vim only)
      :set wrapmargin=15
      :set ignorecase
 Run :help option-list for a complete list
Learning more


 vi/vim built-in help
    :help

    :help topic

    Use :q to exit help

 vimtutor command
Unit 5 vim an advanced text editor

Mais conteúdo relacionado

Mais procurados

Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script Amit Ghosh
 
system management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarsystem management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarGauravRaikar3
 
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
 
Terminal commands ubuntu 2
Terminal commands ubuntu 2Terminal commands ubuntu 2
Terminal commands ubuntu 2raj upadhyay
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2Gourav Varma
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2Kalkey
 
Gnome terminal basics
Gnome terminal basicsGnome terminal basics
Gnome terminal basicsKamrul Hasan
 
Linux commd
Linux commdLinux commd
Linux commdragav03
 
Linux commd
Linux commdLinux commd
Linux commdragav03
 
[PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list [PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list nisivaasdfghj
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent cardBui Van Cuong
 
VI Editors
VI EditorsVI Editors
VI EditorsDeivanai
 

Mais procurados (20)

Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Shell & Shell Script
Shell & Shell Script Shell & Shell Script
Shell & Shell Script
 
system management -shell programming by gaurav raikar
system management -shell programming by gaurav raikarsystem management -shell programming by gaurav raikar
system management -shell programming by gaurav raikar
 
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
 
Terminal commands ubuntu 2
Terminal commands ubuntu 2Terminal commands ubuntu 2
Terminal commands ubuntu 2
 
Ubuntu Terminal
Ubuntu TerminalUbuntu Terminal
Ubuntu Terminal
 
Intro commandline
Intro commandlineIntro commandline
Intro commandline
 
Rhel2
Rhel2Rhel2
Rhel2
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2
 
Vi editor in linux
Vi editor in linuxVi editor in linux
Vi editor in linux
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Gnome terminal basics
Gnome terminal basicsGnome terminal basics
Gnome terminal basics
 
Linux commd
Linux commdLinux commd
Linux commd
 
Linux commd
Linux commdLinux commd
Linux commd
 
[PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list [PDF] 2021 Termux basic commands list
[PDF] 2021 Termux basic commands list
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent card
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
VI Editors
VI EditorsVI Editors
VI Editors
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 

Semelhante a Unit 5 vim an advanced text editor

Introduction to Vim
Introduction to VimIntroduction to Vim
Introduction to VimBrandon Liu
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vimsambismo
 
Augusta Linux User Group - Vim Introduction
Augusta Linux User Group - Vim IntroductionAugusta Linux User Group - Vim Introduction
Augusta Linux User Group - Vim IntroductionKeith Pickett
 
andrew's guide to vim
andrew's guide to vimandrew's guide to vim
andrew's guide to vimAndrew Yi
 
Text editor In RHEL
Text editor In RHELText editor In RHEL
Text editor In RHELVarnnit Jain
 
lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptxpoonam256394
 
Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)MohsinHusenManasiya
 
Linux network manager configure
Linux network manager configureLinux network manager configure
Linux network manager configureInfoExcavator
 
Linux network manager configuration
Linux network manager configurationLinux network manager configuration
Linux network manager configurationMd Meherab Hossen
 
Linux text editors Vim nano
Linux text editors Vim nano Linux text editors Vim nano
Linux text editors Vim nano Md Meherab Hossen
 
1_Editors_in_Unix
1_Editors_in_Unix1_Editors_in_Unix
1_Editors_in_UnixGautam Raja
 
Quick-Start-UNIX.pdf
Quick-Start-UNIX.pdfQuick-Start-UNIX.pdf
Quick-Start-UNIX.pdfHODCA1
 
Lesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxLesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxSadia Bashir
 

Semelhante a Unit 5 vim an advanced text editor (20)

Introduction to Vim
Introduction to VimIntroduction to Vim
Introduction to Vim
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vim
 
Augusta Linux User Group - Vim Introduction
Augusta Linux User Group - Vim IntroductionAugusta Linux User Group - Vim Introduction
Augusta Linux User Group - Vim Introduction
 
andrew's guide to vim
andrew's guide to vimandrew's guide to vim
andrew's guide to vim
 
Text editor In RHEL
Text editor In RHELText editor In RHEL
Text editor In RHEL
 
lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptx
 
Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)
 
Linux network manager configure
Linux network manager configureLinux network manager configure
Linux network manager configure
 
Linux network manager configuration
Linux network manager configurationLinux network manager configuration
Linux network manager configuration
 
Vim knowhow
Vim knowhowVim knowhow
Vim knowhow
 
Linux programming - Getting self started
Linux programming - Getting self started Linux programming - Getting self started
Linux programming - Getting self started
 
Linux text editors Vim nano
Linux text editors Vim nano Linux text editors Vim nano
Linux text editors Vim nano
 
Linux text editors
Linux text editorsLinux text editors
Linux text editors
 
1_Editors_in_Unix
1_Editors_in_Unix1_Editors_in_Unix
1_Editors_in_Unix
 
Vim survival guide
Vim survival guideVim survival guide
Vim survival guide
 
Vim Vi Improved
Vim Vi ImprovedVim Vi Improved
Vim Vi Improved
 
Quick-Start-UNIX.pdf
Quick-Start-UNIX.pdfQuick-Start-UNIX.pdf
Quick-Start-UNIX.pdf
 
swl--3 (1).docx
swl--3 (1).docxswl--3 (1).docx
swl--3 (1).docx
 
Vi editor
Vi editorVi editor
Vi editor
 
Lesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxLesson 3 Working with Files in Linux
Lesson 3 Working with Files in Linux
 

Mais de root_fibo

Unit 13 network client
Unit 13 network clientUnit 13 network client
Unit 13 network clientroot_fibo
 
Unit 12 finding and processing files
Unit 12 finding and processing filesUnit 12 finding and processing files
Unit 12 finding and processing filesroot_fibo
 
Unit3 browsing the filesystem
Unit3 browsing the filesystemUnit3 browsing the filesystem
Unit3 browsing the filesystemroot_fibo
 
Unit 10 investigating and managing
Unit 10 investigating and managingUnit 10 investigating and managing
Unit 10 investigating and managingroot_fibo
 
Unit 9 basic system configuration tools
Unit 9 basic system configuration toolsUnit 9 basic system configuration tools
Unit 9 basic system configuration toolsroot_fibo
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing toolsroot_fibo
 
Unit 7 standard i o
Unit 7 standard i oUnit 7 standard i o
Unit 7 standard i oroot_fibo
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and grouproot_fibo
 

Mais de root_fibo (9)

Unit 13 network client
Unit 13 network clientUnit 13 network client
Unit 13 network client
 
Unit 12 finding and processing files
Unit 12 finding and processing filesUnit 12 finding and processing files
Unit 12 finding and processing files
 
Unit3 browsing the filesystem
Unit3 browsing the filesystemUnit3 browsing the filesystem
Unit3 browsing the filesystem
 
Unit 10 investigating and managing
Unit 10 investigating and managingUnit 10 investigating and managing
Unit 10 investigating and managing
 
Unit 9 basic system configuration tools
Unit 9 basic system configuration toolsUnit 9 basic system configuration tools
Unit 9 basic system configuration tools
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
 
Unit 7 standard i o
Unit 7 standard i oUnit 7 standard i o
Unit 7 standard i o
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and group
 
Unit2 help
Unit2 helpUnit2 help
Unit2 help
 

Último

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Unit 5 vim an advanced text editor

  • 1. RedHat Enterprise Linux Essential Unit 5: vim: An Advanced Text Editor
  • 2. vim: An Advanced Text Editor  Introducing vim  vim: A Modal Editor  vim Basics  Opening a file in vim  Modifying a File Insert Mode  Saving a File and Exiting vim Ex Mode  Using Command Mode  Moving Around Command Mode  Search and Replace Command Mode  Manipulating Text Command Mode  Undoing Changes Command Mode  Visual Mode  Using multiple "windows“  Configuring vi and vim  Learning more
  • 3. Introducing vim  Newer version of vi, the standard Unix text editor  Executing vi runs vim by default  gvim: Graphical version of vim  Applications + Programming -> Vi iMproved  Provided by vim-X11 package  Advantages:  Speed: Do more with fewer keystrokes  Simplicity: No dependence on mouse/GUI  Availability: Included with most Unix-like OSes  Disadvantages  Difficulty: Steeper learning curve than simpler editors • Key bindings emphasize speed over intuitiveness
  • 4. vim Basics  To use vim, you must at least be able to  Open a file  Modify a file (insert mode)  Save a file (ex mode)
  • 5. Opening a file in vim  To start vi:  vim filename  If the file exists, the file is opened and the contents are displayed  If the file does not exist, vi creates it when the edits are saved for the first time
  • 6. Modifying a File Insert Mode  i begins insert mode at the cursor  Many other options exist  A append to end of line  I insert at beginning of line  o insert new a line (below)  O insert new line (above)
  • 7. Saving a File and Exiting vim Ex Mode  Enter Ex Mode with :  Creates a command prompt at bottom-left of screen  Common write/quit commands:  :w writes (saves) the file to disk  :wq writes and quits  :q! quits, even if changes are lost
  • 8. Using Command Mode  Default mode of vim  Keys describe movement and text manipulation commands  Commands repeat when preceded by a number  Example  Right Arrow moves right one character  5, Right Arrow moves right five characters
  • 9. Moving Around Command Mode  Move by character: Arrow Keys, h, j, k, l  Non-arrow keys useful for remote connections to older systems  Move by word: w, b  Move by sentence: ), (  Move by paragraph: }, {  Jump to line x: xG  Jump to end: G
  • 10. Search and Replace Command Mode  Search as in less  /, n, N  Search/Replace as in sed  Affects current line by default  Use x,y ranges or % for whole file :1,5s/cat/dog/ :%s/cat/dog/gi
  • 12. Undoing Changes Command Mode  u undo most recent change  U undo all changes to the current line since the cursor landed on the line  Ctrl-r redo last "undone" change
  • 13. Visual Mode  Allows selection of blocks of text  v starts character-oriented highlighting  V starts line-oriented highlighting  Activated with mouse in gvim  Visual keys can be used in conjunction with movement keys:  w, ), }, arrows, etc  Highlighted text can be deleted, yanked, changed, filtered, search/replaced, etc.
  • 14. Using multiple "windows"  Multiple documents can be viewed in a single vim screen. $ vim –o ~/.bashrc ~/.bash_profile  Ctrl-w, s splits the screen horizontally  Ctrl-w, v splits the screen vertically  Ctrl-w, Arrow moves between windows  Ex-mode instructions always affect the current window  :help windows displays more window commands
  • 15. Configuring vi and vim  Configuring on the fly :set or :set all  Configuring permanently ~/.vimrc or ~/.exrc  A few common configuration items  :set number  :set autoindent  :set textwidth=65 (vim only)  :set wrapmargin=15  :set ignorecase  Run :help option-list for a complete list
  • 16. Learning more  vi/vim built-in help  :help  :help topic  Use :q to exit help  vimtutor command