SlideShare a Scribd company logo
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

Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System Calls
Vandana Salve
 
Linux commands
Linux commandsLinux commands
Linux commands
Mannu Khani
 
Vi editor
Vi editorVi editor
Vi editor
Ramakrishna kapa
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
VIKAS TIWARI
 
Introduction to the linux command line.pdf
Introduction to the linux command line.pdfIntroduction to the linux command line.pdf
Introduction to the linux command line.pdf
CesleySCruz
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File Management
Damian T. Gordon
 
Know the UNIX Commands
Know the UNIX CommandsKnow the UNIX Commands
Know the UNIX Commands
Brahma Killampalli
 
Basic command ppt
Basic command pptBasic command ppt
Basic command pptRohit Kumar
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
Aliya Saldanha
 
scope of python
scope of pythonscope of python
scope of python
Dwarak Besant
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
shravan saini
 
Vi editor
Vi editorVi editor
Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
Mohammad Rafiee
 
Personalising Desktop
Personalising DesktopPersonalising Desktop
Personalising Desktop
Ajay Jassi
 
Operating system
Operating systemOperating system
Operating system
himabindukursam
 
Networking in linux
Networking in linuxNetworking in linux
Networking in linux
Varnnit Jain
 
Windows installation
Windows installationWindows installation
Windows installation
Zeeshan_5858
 
Daemons
DaemonsDaemons
Daemons
christina555
 

What's hot (20)

Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System Calls
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Vi editor
Vi editorVi editor
Vi editor
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
Introduction to the linux command line.pdf
Introduction to the linux command line.pdfIntroduction to the linux command line.pdf
Introduction to the linux command line.pdf
 
Booting
BootingBooting
Booting
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File Management
 
Know the UNIX Commands
Know the UNIX CommandsKnow the UNIX Commands
Know the UNIX Commands
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
 
scope of python
scope of pythonscope of python
scope of python
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
Vi editor
Vi editorVi editor
Vi editor
 
Linux System Monitoring basic commands
Linux System Monitoring basic commandsLinux System Monitoring basic commands
Linux System Monitoring basic commands
 
Personalising Desktop
Personalising DesktopPersonalising Desktop
Personalising Desktop
 
Operating system
Operating systemOperating system
Operating system
 
Networking in linux
Networking in linuxNetworking in linux
Networking in linux
 
Windows installation
Windows installationWindows installation
Windows installation
 
Daemons
DaemonsDaemons
Daemons
 

Viewers also liked

Vi editor
Vi editorVi editor
The "vi" Text Editor
The "vi" Text EditorThe "vi" Text Editor
The "vi" Text Editor
Alessandro Manfredi
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
anandvaidya
 
Unix operating system
Unix operating systemUnix operating system
Unix operating system
ABhay 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 Editor
techbed
 
Introduction to vi editor
Introduction to vi editorIntroduction to vi editor
Introduction to vi editorU.P Police
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
Bwsrang Basumatary
 
Introduction to unix
Introduction to unixIntroduction to unix
Introduction to unix
sudheer yathagiri
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operationsmussawir20
 
Linux files
Linux filesLinux files
Linux files
Geeta Vinnakota
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
Mohamed Loey
 
Linux Network commands
Linux Network commandsLinux Network commands
Linux Network commands
Hanan 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 commands
Linux commandsLinux commands
Linux commands
 
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
 

Similar to Vi Editor

07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
Shay Cohen
 
Presentacion vim
Presentacion vimPresentacion vim
Presentacion vimIcalia Labs
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
hazhamina
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editor
shanmuga rajan
 
Linux text editors Vim nano
Linux text editors Vim nano Linux text editors Vim nano
Linux text editors Vim nano
Md Meherab Hossen
 
Linux text editors
Linux text editorsLinux text editors
Linux text editors
InfoExcavator
 
Linuxppt
LinuxpptLinuxppt
LinuxpptReka
 
Linux basic1&amp;2
Linux basic1&amp;2Linux basic1&amp;2
Linux basic1&amp;2
Hideo Amezawa
 
lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptx
poonam256394
 
Vim
VimVim
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
 
Lpt lopsa
Lpt lopsaLpt lopsa
Lpt lopsa
ketancmaheshwari
 
Vim Cheat Sheet.pdf
Vim Cheat Sheet.pdfVim Cheat Sheet.pdf
Vim Cheat Sheet.pdf
AdelinaBronda1
 
Linux
LinuxLinux

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
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editor
 
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
 

More from Shiwang Kalkhanda

Why linux is better than windows
Why linux is better than windowsWhy linux is better than windows
Why linux is better than windows
Shiwang Kalkhanda
 
Intro to operating_system
Intro to operating_systemIntro to operating_system
Intro to operating_system
Shiwang Kalkhanda
 
Intro to libre_office
Intro to libre_officeIntro to libre_office
Intro to libre_office
Shiwang Kalkhanda
 
Intro to open_source
Intro to open_sourceIntro to open_source
Intro to open_source
Shiwang Kalkhanda
 
History of linux
History of linuxHistory of linux
History of linux
Shiwang Kalkhanda
 
Cryptoparty Handbook
Cryptoparty HandbookCryptoparty Handbook
Cryptoparty Handbook
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

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 

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. ?