SlideShare a Scribd company logo
1 of 30
Download to read offline
VI - EDITOR
INTODUCTION TO VIM
• vi → The standard Unix text editor
• vim → vi improved is a powerful text editor
• gvim → Graphical version of vim
• Advantages of Vi / Vim :
– Speed : Do more with fewer keystrokes
– Simplicity : No dependence on mouse/GUI
– Availability : Included with most Unix / Linux Distro
• Disadvantages of Vi/Vim :
– Difficult : Steeper learning curve than simpler editors
VI MODES OF WORKING
• Keystroke behavior is dependent upon vim's "mode"
• Three main modes:
– Command Mode (default) : Move cursor, cut / copy / paste /
or delete text in file
– Insert Mode : Modify text in file
– Ex Mode : Save, Quit, Customize etc
• <Esc key > : exits current mode into
command mode.
• NOTE : When in doubt press Escape key, you will be back in
command mode
OPEN A FILE IN VI / VIM
• To start vi / vim :
– # vim filename
– # vi +number filename ( open file and put cursor at line number
specified )
• 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
• By default vi has unnamed temporary buffer where file is edited
MODIFY A FILE : INSERT MODE
• INSERT MODE → To insert the text in file we should be in Insert
mode
– i → inserts the text before cursor location
– I → insert at beginning of line
– a → inserts text after cursor location
– A → insert at end of line
– I → insert at beginning of line
– o → insert new line (below)
– O → insert new line (above)
– S → deletes the character under cursor and get into insert
mode
MODIFY A FILE : REPLACING TEXT
• ONE CHARACTER AT A TIME → Replacing text also happens in
insert mode as follows :
– r → replace a single character
– R → replace multiple char( will be in replace mode )
SAVE & EXIT FILE : EX MODE
• Enter Ex Mode by pressing → :
– Creates a command prompt at bottom-left of screen
• Common write/quit commands :
– :q <enter key> → quits the vi only if no changes have been made
to the file being edited
– :q! <enter key> → quits the vi without making any changes in file
– :w <enter key> → writes (saves) the file to disk only
– :wq <enter key> → writes the buffer and quits vi
– :ZZ <enter key> → writes the buffer and quits vi
– :x <enter key> → writes and quits
WRITE TO FILE : EX MODE
• Common write commands :
– :w <enter key> → writes (saves) the file to disk only
– :wq <enter key> → writes the buffer and quits vi
– :f <filename> → renames current file to filename
– :w <filename> → write the file to path / filename given
– :w>> filename → append current file to the filename given
– :5,10w filename → write lines 5 through 10 to the filename given
– :5,10w>>filename→ append lines 5 through 10 to the filename given
– :r <filename> → read a copy of file into current file at cursor
positon
– :e <filename> → opens another file with filename
– :e# <enter key> → switch between the open vi windows ******** (this
works after saving the file once on disk using :w )
USING COMMAND MODE
• Default mode of vim
• Keys describe movement and text manipulation commands
• Commands repeat when preceded by a numberCommands repeat when preceded by a number
• Example
– Right Arrow : moves right 1 character
– 5 followed by Right Arrow : moves right 5 characters
MOVING AROUND : COMMAND MODE
• Move by character : Arrow Keys, h, j, k, l
( Non-arrow keys useful for remote connections to older systems )
MOVING AROUND : COMMAND MODE
• MOVE BY WORD
• w : moves the cursor forward one word
• b : moves cursor back one word
• e : moves cursor to the end of current word
• MOVE BY LINE
• ^ : moves cursor to the beginning of current line
• $ : moves to the end of current line
• MOVE BY SENTENCE
• ( : moves to the beginning of previous sentence
• ) : moves to the end of next sentence
MOVING AROUND : COMMAND MODE
• MOVE BY PARAGRAPH
• { : moves to the beginning of previous paragraph
• } : moves to the end of next paragraph
• MOVE BY SCREEN
• <ctrl>f : moves forward one screen
• <ctrl>b : moves back one screen
• <ctrl>d : moves down half screen
• <ctrl>u : moves up half screen
• H : first line on screen
• M : middle line on the screen
• L : last line on the screen
MOVING AROUND : COMMAND MODE
• MOVE INSIDE WHOLE DOCUMENT
• nG : move to nth line of file (****in command mode*****)
• :n : move to nth line of file (****in ex mode****)
• 1G : first line of the document / file
• G : last line of the file
• 25G : 25th
line of the file ( in command mode )
• :25 : 25th
line of the file ( in ex mode )
SEARCH : EX MODE
• Same implementation as in less editor
• /<pattern> – search forward in buffer for next occurrence of the
pattern of text.
• ?<pattern> – search backwards
• n – Repeats the last search command
• N – Repeats the search command in opposite
direction
• We can use regular expression in searches
SUBSTITUTION : EX MODE
• By default substitute the first occurrence of text on current line
– : s/file/book/ ( first occurrence of file with book on current
line )
– :s/file/book/g ( all the occurrence of file with book on
current line )
• Use x,y ranges
– :1,5s/cat/dog/ ( first occurrence of cat with dog between
line 1 to line 5 )
– :1,5s/cat/dog/g ( all occurrence of cat with dog between line
1 to line 5 )
• Use % for whole file
– :%s/cat/dog/ ( substitute first occurrence of cat with dog in
full file )
– :%s/cat/dog/g ( substitute all occurrence of cat with dog in
full file )
– :%s/cat/dog/gc ( c → prompt before each substitution )
DELETING TEXT : COMMAND MODE
• DELETING SINGLE CHARACTERS
– x → Deletes a character at current cursor position
– 3x → Deletes the character currently under cursor
followed bye two
– Nx → Deletes n-1 characters on right of cursor position
– X → Deletes a character to the left of the cursor
• NOTE : Deleting puts the text in unnamed temporary
buffer which can be used for paste operation at
other place, and thus becomes cut paste *******
DELETING TEXT : COMMAND MODE
• DELETING LARGER CHUNKS
– dw → deletes a word (or part of a word) from the cursor to the next
space or to the next punctuation.
– db → delete one word backwards
– d$ → deletes the current line from the cursor to the end of the line
– d^ → deletes the current line from the cursor to the beginning of the
line
– d0 → same as d^
– d) → delete one sentence forward
– d( → delete one sentence backwards
– dG → delete from current line to the end of file
– dgg → delete from current line to the beginning of file
– dd → deletes the current line *******
– ndw → deletes n words from current cursor position
– ndd → deletes n lines from current line *******
COPY TEXT : COMMAND MODE
• COPY / YANKING → yank command puts the text in temp buffer for copy
– yw → yank a word forward
– yb → one word backwards
– y$ → yank the current line from the cursor to the end of the line
– y^ → yank the current line from the cursor to the beginning of the
line
– y0 → same as d^
– y) → yank one sentence forward
– y( → yank one sentence backwards
– yG → yank from current line to the end of file
– ygg → yank from current line to the beginning of file
– yy → yank the current line *******
– nyw → yank n words from current cursor position
– nyy → yank n lines from current line *******
– 20yy → yank 20 lines from current line *******
• P → 'PUT' comman for paste operation, place the contents
of the unnamed buffer back into the file. ( Buffered content
of delete & yank command )
– p → Paste the content below the current line
– P → Paste the content above the current line
PASTE TEXT : COMMAND MODE
UNDO 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
USING MULTIPLE “WINDOWS”
• View multiple documents in a single vim screen.
– Ctrl-w followed by s → s splits the screen horizontally
– Ctrl-w followed by v → v splits the screen vertically
– Ctrl-w followed by arrow → Arrow moves between windows
– Ctrl-w followed by q → quit / close open windows
• Ex-mode instructions always affect the current window
• :help windows displays more window commands
CUSTOMIZING VI SESSION
• A few common configuration items
– :set all - Display all options
– :set - Display current setting of
options
– :set number / :set nu - Display line numbers
– ( This can be useful when deleting or substituting selected text
as follows )
– :2,10d - Delete line 2 to 10
– :1,10s/foo/bar/g - Substitute foo with bar
from line 1 to 10
– :set nonumber / :set nonu - Hide line numbers
CUSTOMIZING VI SESSION
• A few common configuration items
– :set all - Display all options
– :set - Display current setting of
options
– :set autoindent or :set ai - Turn on autoindenting
– :set textwidth=65 (vim only)
– :set wrapmargin=15 / :set wm=15 - Set wrap margin 15
spaces from right edge
of screen
– :set wrapmargin=0 / :set wm=0 - Turn off Wrap margin
– :set ignorecase or :set ic - Set ignore case during
searches
– :syntax on - Turn on syntax
highlighting
– :syntax off - Turn off syntax
hightlighting
CUSTOMIZING VI SESSION
• Options can be set in the following ways
– During a vi session
• :set nu / :set nonu ...etc ( preserve setting for that session)
– For permanent setting for a user.
• Create either ~/.vimrc or ~/.exrc file in user home directory
Sample contents of .exrc are →
set nu
set ai
set wm=10
ABBREVIATIONS
• ABBREVIATIONS → are text strings which automatically expand
to larger string when used in Insert Mode ( use .vimrc for
permanent changes )
• To add an abbreviation
– :ab UW University of Delhi
(Now if in insert mode I enter UW it be expanded to University of
Delhi on entering any non-alphanumeric character)
• To list currently defined abbreviations
– :ab
• To disable / delete an abbreviation use the :unab command
– :unab UW → clears the given abbreviation
– :abc → clear all the set abbreviation
MAPPING
• MAPPING → any key can be mapped as shortcut for command.
( For making permanent changes use .vimrc )
• To add a key map
– :map – dd (it creates a key map that works in command mode)
– :map! @ dd (it creates a key map that works in insert mode)
• To list currently defined map keys
– :map
– :map!
• To remove a keymap
– :unmap -
– :unmap @
USEFUL TIPS
• Launch vi and begin editing <filename> at line 125
– # vi +125 <filename>
• Launch vi and edit multiple files
– # vi <file1> <file2> (switch to next file using :n)
• Change case of character under cursor
– ~ ( press tilde key at current cursor positon)
• Join the current line and the next line
– J ( capital J in command mode )
• Remove null lines in the file
– : g/^$/d
• List all occurrences of the word 'foo' with line numbers
– :g/foo/#
• Read output from a Unix shell command into current text
– :r !<command>
USEFUL TIPS
• Get the line number of current cursor positon
– Ctrl + g
• Repeats the action performed by last command
– . ( press . In command mode )
• Temporarily returns to the shell to perform shell commands
– :sh ( Type exit to return to vi )
• Execute a command from vi editor ex mode
– :! <command>
LEARNING MORE
• vi/vim built-in help
• :help topic
• :help
• Use :q to exit help
• vimtutor command
• NOTE → USERS WITH UIDs > 200 WHEN TYPE VI WILL
GET VIM EDITOR ( Because of alias of vi )
?

More Related Content

What's hot (20)

Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
Vi editor
Vi editorVi editor
Vi editor
 
Basic 50 linus command
Basic 50 linus commandBasic 50 linus command
Basic 50 linus command
 
Object Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical FileObject Oriented Programming Using C++ Practical File
Object Oriented Programming Using C++ Practical File
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Vi editor Linux Editors
Vi editor Linux EditorsVi editor Linux Editors
Vi editor Linux Editors
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Sets in python
Sets in pythonSets in python
Sets in python
 
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
Sa1 chapter-5-managing-local-linux-users-and-groups-v2 (4)
 
Cp command in Linux
Cp command in LinuxCp command in Linux
Cp command in Linux
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Linux Run Level
Linux Run LevelLinux Run Level
Linux Run Level
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and Permissions
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)
 
Unix ppt
Unix pptUnix ppt
Unix ppt
 
Users and groups
Users and groupsUsers and groups
Users and groups
 
Linux basic commands with examples
Linux basic commands with examplesLinux basic commands with examples
Linux basic commands with examples
 

Viewers also liked

Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)anandvaidya
 
Unix operating system
Unix operating systemUnix operating system
Unix operating systemABhay Panchal
 
Unix Internals OS Architecture
Unix Internals OS ArchitectureUnix Internals OS Architecture
Unix Internals OS ArchitectureKhader Shaik
 
Even internet computers want to be free: Using Linux and open source software...
Even internet computers want to be free: Using Linux and open source software...Even internet computers want to be free: Using Linux and open source software...
Even internet computers want to be free: Using Linux and open source software...North Bend Public Library
 
Using VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarUsing VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarRohit Kumar
 
1359 Vi Editor
1359 Vi Editor1359 Vi Editor
1359 Vi Editortechbed
 
Introduction to vi editor
Introduction to vi editorIntroduction to vi editor
Introduction to vi editorU.P Police
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operationsmussawir20
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive OverviewMohamed Loey
 
Linux Network commands
Linux Network commandsLinux Network commands
Linux Network commandsHanan Nmr
 

Viewers also liked (20)

Vi editor
Vi   editorVi   editor
Vi editor
 
Vi editor
Vi editorVi editor
Vi editor
 
The "vi" Text Editor
The "vi" Text EditorThe "vi" Text Editor
The "vi" Text Editor
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
 
Unix operating system
Unix operating systemUnix operating system
Unix operating system
 
Unix Internals OS Architecture
Unix Internals OS ArchitectureUnix Internals OS Architecture
Unix Internals OS Architecture
 
Even internet computers want to be free: Using Linux and open source software...
Even internet computers want to be free: Using Linux and open source software...Even internet computers want to be free: Using Linux and open source software...
Even internet computers want to be free: Using Linux and open source software...
 
Using VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarUsing VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit Kumar
 
1359 Vi Editor
1359 Vi Editor1359 Vi Editor
1359 Vi Editor
 
Introduction to vi editor
Introduction to vi editorIntroduction to vi editor
Introduction to vi editor
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
Introduction to unix
Introduction to unixIntroduction to unix
Introduction to unix
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operations
 
Linux files
Linux filesLinux files
Linux files
 
Dma
DmaDma
Dma
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
 
Php ppt
Php pptPhp ppt
Php ppt
 
Linux Network commands
Linux Network commandsLinux Network commands
Linux Network commands
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
php
phpphp
php
 

Similar to Vi Editor (20)

07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
 
Presentacion vim
Presentacion vimPresentacion vim
Presentacion vim
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
Using vi
Using viUsing vi
Using vi
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
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
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linux basic1&amp;2
Linux basic1&amp;2Linux basic1&amp;2
Linux basic1&amp;2
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptx
 
Vim and Python
Vim and PythonVim and Python
Vim and Python
 
Vim
VimVim
Vim
 
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
 
Lpt lopsa
Lpt lopsaLpt lopsa
Lpt lopsa
 
Vim Cheat Sheet.pdf
Vim Cheat Sheet.pdfVim Cheat Sheet.pdf
Vim Cheat Sheet.pdf
 
Linex
LinexLinex
Linex
 
Linux
LinuxLinux
Linux
 
Basic linux day 4
Basic linux day 4Basic linux day 4
Basic linux day 4
 
Tuffarsi in vim
Tuffarsi in vimTuffarsi in vim
Tuffarsi in vim
 

More from Shiwang Kalkhanda

More from Shiwang Kalkhanda (7)

Why linux is better than windows
Why linux is better than windowsWhy linux is better than windows
Why linux is better than windows
 
Intro to operating_system
Intro to operating_systemIntro to operating_system
Intro to operating_system
 
Intro to libre_office
Intro to libre_officeIntro to libre_office
Intro to libre_office
 
Intro to open_source
Intro to open_sourceIntro to open_source
Intro to open_source
 
History of linux
History of linuxHistory of linux
History of linux
 
Cryptoparty Handbook
Cryptoparty HandbookCryptoparty Handbook
Cryptoparty Handbook
 
Before begining linux
Before begining linuxBefore begining linux
Before begining linux
 

Recently uploaded

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Recently uploaded (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Vi Editor

  • 2. INTODUCTION TO VIM • vi → The standard Unix text editor • vim → vi improved is a powerful text editor • gvim → Graphical version of vim • Advantages of Vi / Vim : – Speed : Do more with fewer keystrokes – Simplicity : No dependence on mouse/GUI – Availability : Included with most Unix / Linux Distro • Disadvantages of Vi/Vim : – Difficult : Steeper learning curve than simpler editors
  • 3. VI MODES OF WORKING • Keystroke behavior is dependent upon vim's "mode" • Three main modes: – Command Mode (default) : Move cursor, cut / copy / paste / or delete text in file – Insert Mode : Modify text in file – Ex Mode : Save, Quit, Customize etc • <Esc key > : exits current mode into command mode. • NOTE : When in doubt press Escape key, you will be back in command mode
  • 4. OPEN A FILE IN VI / VIM • To start vi / vim : – # vim filename – # vi +number filename ( open file and put cursor at line number specified ) • 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 • By default vi has unnamed temporary buffer where file is edited
  • 5. MODIFY A FILE : INSERT MODE • INSERT MODE → To insert the text in file we should be in Insert mode – i → inserts the text before cursor location – I → insert at beginning of line – a → inserts text after cursor location – A → insert at end of line – I → insert at beginning of line – o → insert new line (below) – O → insert new line (above) – S → deletes the character under cursor and get into insert mode
  • 6. MODIFY A FILE : REPLACING TEXT • ONE CHARACTER AT A TIME → Replacing text also happens in insert mode as follows : – r → replace a single character – R → replace multiple char( will be in replace mode )
  • 7. SAVE & EXIT FILE : EX MODE • Enter Ex Mode by pressing → : – Creates a command prompt at bottom-left of screen • Common write/quit commands : – :q <enter key> → quits the vi only if no changes have been made to the file being edited – :q! <enter key> → quits the vi without making any changes in file – :w <enter key> → writes (saves) the file to disk only – :wq <enter key> → writes the buffer and quits vi – :ZZ <enter key> → writes the buffer and quits vi – :x <enter key> → writes and quits
  • 8. WRITE TO FILE : EX MODE • Common write commands : – :w <enter key> → writes (saves) the file to disk only – :wq <enter key> → writes the buffer and quits vi – :f <filename> → renames current file to filename – :w <filename> → write the file to path / filename given – :w>> filename → append current file to the filename given – :5,10w filename → write lines 5 through 10 to the filename given – :5,10w>>filename→ append lines 5 through 10 to the filename given – :r <filename> → read a copy of file into current file at cursor positon – :e <filename> → opens another file with filename – :e# <enter key> → switch between the open vi windows ******** (this works after saving the file once on disk using :w )
  • 9. USING COMMAND MODE • Default mode of vim • Keys describe movement and text manipulation commands • Commands repeat when preceded by a numberCommands repeat when preceded by a number • Example – Right Arrow : moves right 1 character – 5 followed by Right Arrow : moves right 5 characters
  • 10. MOVING AROUND : COMMAND MODE • Move by character : Arrow Keys, h, j, k, l ( Non-arrow keys useful for remote connections to older systems )
  • 11. MOVING AROUND : COMMAND MODE • MOVE BY WORD • w : moves the cursor forward one word • b : moves cursor back one word • e : moves cursor to the end of current word • MOVE BY LINE • ^ : moves cursor to the beginning of current line • $ : moves to the end of current line • MOVE BY SENTENCE • ( : moves to the beginning of previous sentence • ) : moves to the end of next sentence
  • 12. MOVING AROUND : COMMAND MODE • MOVE BY PARAGRAPH • { : moves to the beginning of previous paragraph • } : moves to the end of next paragraph • MOVE BY SCREEN • <ctrl>f : moves forward one screen • <ctrl>b : moves back one screen • <ctrl>d : moves down half screen • <ctrl>u : moves up half screen • H : first line on screen • M : middle line on the screen • L : last line on the screen
  • 13. MOVING AROUND : COMMAND MODE • MOVE INSIDE WHOLE DOCUMENT • nG : move to nth line of file (****in command mode*****) • :n : move to nth line of file (****in ex mode****) • 1G : first line of the document / file • G : last line of the file • 25G : 25th line of the file ( in command mode ) • :25 : 25th line of the file ( in ex mode )
  • 14. SEARCH : EX MODE • Same implementation as in less editor • /<pattern> – search forward in buffer for next occurrence of the pattern of text. • ?<pattern> – search backwards • n – Repeats the last search command • N – Repeats the search command in opposite direction • We can use regular expression in searches
  • 15. SUBSTITUTION : EX MODE • By default substitute the first occurrence of text on current line – : s/file/book/ ( first occurrence of file with book on current line ) – :s/file/book/g ( all the occurrence of file with book on current line ) • Use x,y ranges – :1,5s/cat/dog/ ( first occurrence of cat with dog between line 1 to line 5 ) – :1,5s/cat/dog/g ( all occurrence of cat with dog between line 1 to line 5 ) • Use % for whole file – :%s/cat/dog/ ( substitute first occurrence of cat with dog in full file ) – :%s/cat/dog/g ( substitute all occurrence of cat with dog in full file ) – :%s/cat/dog/gc ( c → prompt before each substitution )
  • 16. DELETING TEXT : COMMAND MODE • DELETING SINGLE CHARACTERS – x → Deletes a character at current cursor position – 3x → Deletes the character currently under cursor followed bye two – Nx → Deletes n-1 characters on right of cursor position – X → Deletes a character to the left of the cursor • NOTE : Deleting puts the text in unnamed temporary buffer which can be used for paste operation at other place, and thus becomes cut paste *******
  • 17. DELETING TEXT : COMMAND MODE • DELETING LARGER CHUNKS – dw → deletes a word (or part of a word) from the cursor to the next space or to the next punctuation. – db → delete one word backwards – d$ → deletes the current line from the cursor to the end of the line – d^ → deletes the current line from the cursor to the beginning of the line – d0 → same as d^ – d) → delete one sentence forward – d( → delete one sentence backwards – dG → delete from current line to the end of file – dgg → delete from current line to the beginning of file – dd → deletes the current line ******* – ndw → deletes n words from current cursor position – ndd → deletes n lines from current line *******
  • 18. COPY TEXT : COMMAND MODE • COPY / YANKING → yank command puts the text in temp buffer for copy – yw → yank a word forward – yb → one word backwards – y$ → yank the current line from the cursor to the end of the line – y^ → yank the current line from the cursor to the beginning of the line – y0 → same as d^ – y) → yank one sentence forward – y( → yank one sentence backwards – yG → yank from current line to the end of file – ygg → yank from current line to the beginning of file – yy → yank the current line ******* – nyw → yank n words from current cursor position – nyy → yank n lines from current line ******* – 20yy → yank 20 lines from current line *******
  • 19. • P → 'PUT' comman for paste operation, place the contents of the unnamed buffer back into the file. ( Buffered content of delete & yank command ) – p → Paste the content below the current line – P → Paste the content above the current line PASTE TEXT : COMMAND MODE
  • 20. UNDO 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
  • 21. USING MULTIPLE “WINDOWS” • View multiple documents in a single vim screen. – Ctrl-w followed by s → s splits the screen horizontally – Ctrl-w followed by v → v splits the screen vertically – Ctrl-w followed by arrow → Arrow moves between windows – Ctrl-w followed by q → quit / close open windows • Ex-mode instructions always affect the current window • :help windows displays more window commands
  • 22. CUSTOMIZING VI SESSION • A few common configuration items – :set all - Display all options – :set - Display current setting of options – :set number / :set nu - Display line numbers – ( This can be useful when deleting or substituting selected text as follows ) – :2,10d - Delete line 2 to 10 – :1,10s/foo/bar/g - Substitute foo with bar from line 1 to 10 – :set nonumber / :set nonu - Hide line numbers
  • 23. CUSTOMIZING VI SESSION • A few common configuration items – :set all - Display all options – :set - Display current setting of options – :set autoindent or :set ai - Turn on autoindenting – :set textwidth=65 (vim only) – :set wrapmargin=15 / :set wm=15 - Set wrap margin 15 spaces from right edge of screen – :set wrapmargin=0 / :set wm=0 - Turn off Wrap margin – :set ignorecase or :set ic - Set ignore case during searches – :syntax on - Turn on syntax highlighting – :syntax off - Turn off syntax hightlighting
  • 24. CUSTOMIZING VI SESSION • Options can be set in the following ways – During a vi session • :set nu / :set nonu ...etc ( preserve setting for that session) – For permanent setting for a user. • Create either ~/.vimrc or ~/.exrc file in user home directory Sample contents of .exrc are → set nu set ai set wm=10
  • 25. ABBREVIATIONS • ABBREVIATIONS → are text strings which automatically expand to larger string when used in Insert Mode ( use .vimrc for permanent changes ) • To add an abbreviation – :ab UW University of Delhi (Now if in insert mode I enter UW it be expanded to University of Delhi on entering any non-alphanumeric character) • To list currently defined abbreviations – :ab • To disable / delete an abbreviation use the :unab command – :unab UW → clears the given abbreviation – :abc → clear all the set abbreviation
  • 26. MAPPING • MAPPING → any key can be mapped as shortcut for command. ( For making permanent changes use .vimrc ) • To add a key map – :map – dd (it creates a key map that works in command mode) – :map! @ dd (it creates a key map that works in insert mode) • To list currently defined map keys – :map – :map! • To remove a keymap – :unmap - – :unmap @
  • 27. USEFUL TIPS • Launch vi and begin editing <filename> at line 125 – # vi +125 <filename> • Launch vi and edit multiple files – # vi <file1> <file2> (switch to next file using :n) • Change case of character under cursor – ~ ( press tilde key at current cursor positon) • Join the current line and the next line – J ( capital J in command mode ) • Remove null lines in the file – : g/^$/d • List all occurrences of the word 'foo' with line numbers – :g/foo/# • Read output from a Unix shell command into current text – :r !<command>
  • 28. USEFUL TIPS • Get the line number of current cursor positon – Ctrl + g • Repeats the action performed by last command – . ( press . In command mode ) • Temporarily returns to the shell to perform shell commands – :sh ( Type exit to return to vi ) • Execute a command from vi editor ex mode – :! <command>
  • 29. LEARNING MORE • vi/vim built-in help • :help topic • :help • Use :q to exit help • vimtutor command • NOTE → USERS WITH UIDs > 200 WHEN TYPE VI WILL GET VIM EDITOR ( Because of alias of vi )
  • 30. ?