Linux Operating System A Practical Guide to Fedora

  • Slides: 15
Download presentation
Linux Operating System A Practical Guide to Fedora and Red Hat Enterprise Linux Chapter

Linux Operating System A Practical Guide to Fedora and Red Hat Enterprise Linux Chapter 5: The vim Editor By Fred R. Mc. Clurg © Copyright 2016, All Rights Reserved

Install for this class … vi, vim, gvim: yum install vim-X 11 ascii man

Install for this class … vi, vim, gvim: yum install vim-X 11 ascii man page: yum install man-pages

vi, vim, gvim: Visual Editor Syntax: gvim filename

vi, vim, gvim: Visual Editor Syntax: gvim filename

vim: Modes of Operation �Command Mode: Accepts vim commands �Input Mode: Accepts any text

vim: Modes of Operation �Command Mode: Accepts vim commands �Input Mode: Accepts any text cursor mode indicator line number column number percent content Escape Key: Toggles between Command Input Modes

vim: Command Modes �Vi Command Mode: ◦ Short (usually one or two) character commands

vim: Command Modes �Vi Command Mode: ◦ Short (usually one or two) character commands �Ex Command Mode: ◦ Always begins with colon

Vi Commands

Vi Commands

vi: Cursor Movement Commands goto first line of file home (top of screen) line

vi: Cursor Movement Commands goto first line of file home (top of screen) line up begin line middle screen ^ begin text 0 h left line down lower (btm of screen) goto last line of file 1 G H k M j L G end of line l $ right

vi: Insert/Append Commands append line open above cursor position insert line I i insert

vi: Insert/Append Commands append line open above cursor position insert line I i insert left open below O □ o a A append right

vi: Move by word, sentence, paragraph up { sentence up back big word B

vi: Move by word, sentence, paragraph up { sentence up back big word B end word b back word sentence down paragraph down curso r ( □ ) } w e word end big word W E word big

vi: Delete Commands cursor position delete previous X delete character □x D delete to

vi: Delete Commands cursor position delete previous X delete character □x D delete to line end

vi: Delete and Change Cmd cw cc dw dd Description Change word Change line

vi: Delete and Change Cmd cw cc dw dd Description Change word Change line Delete word Delete line into buffer named "add “a”

vi: Yank and Put Commands Cmd Y yy P p "ayy "ap Description Yank

vi: Yank and Put Commands Cmd Y yy P p "ayy "ap Description Yank (copy) line Put (paste) yanked line above Put (paste) yanked line below Yank line into buffer named “a” Put line from named buffer “a”

vi: Find string commands Cmd Description Define and find string /str “str” Define &

vi: Find string commands Cmd Description Define and find string /str “str” Define & find previous ? str “str” n N Find next string occurrence Find previous occurrence

Ex Commands

Ex Commands

ex: Editing Files Syntax: ◦ : e file ◦ : e! ◦ : w

ex: Editing Files Syntax: ◦ : e file ◦ : e! ◦ : w file ◦ : q! ◦ : wq ◦ : n ◦ ZZ exit Edit file “filename” Revert file to last save Write file “filename” Quit the editor Quit without saving Write file and quit editor Next file Write file (if modified) and