Download presentation
Presentation is loading. Please wait.
Published bySherilyn Abigail Dawson Modified over 6 years ago
1
IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
The vim Editor (ch 6) IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
2
What’s vim vi iMproved Text editor Scripts Codes (C, Java, HTML)
Configure files and short notes No format
3
Get Started Starting vim vim practice Emergency exit ESC, then “:q!”
4
Command and Input Modes
5
Command and Input Modes
Command mode example :set number Enter input mode i / a : insert / append Back to command mode (ESC) Save the file and quit ZZ
6
Moving the Cursor In command mode In input mode Space, enter
Arrow keys h, j, k, l In input mode
7
Edit Text Delete text In command mode In input mode
x: delete a character dw: delete a word dd: delete a line In input mode backspace
8
Edit Text Add text Undo and redo In command mode
i: insert (at the current cursor) a: append (precede the current cursor) o/O: open a new line (below/above) Undo and redo u :redo
9
Edit Text Work buffer Readonly mode Write to disk Quit (:q)
Your editing is not automatically saved Readonly mode view filename vim -R filename Write to disk :w [filename] Quit (:q)
10
More about Moving the Cursor
Space, Enter, {h,j,k,l} Search for a character in a line f/F fc, fa, Fc Repeat the last search: ; Moving by words w/W, b/B
11
More about Moving the Cursor
Moving by words
12
More about Moving the Cursor
Moving by lines j/k, up arrow/down arrow Enter/-
13
More about Moving the Cursor
Moving by sentences/paragraphs ) , ( , } , { Moving within the screen H/M/L: top/middle/bottom line
14
More about Moving the Cursor
15
More about Moving the Cursor
Page down/up CTRL+D / CTRL+U (half screen) CTRL+F / CTRL+B (full screen) Line numbers :set number #G
16
Input Mode Insert text i/I , a/A, o/O
17
Delete Text Table 6-1 (Pg 181) dw, d3w d0, d$ d), d(, d4), d{, d}
dd, 5dd, dL d (enter), D
18
Change Text Table 6-2 (Pg 182) Change case cw, c3w c0, c$
c), c(, c4), c{, c} cc, 5cc, cL Change case ~, 5~
19
Search and Replace Search for a character Search for a string
f/F, t/T, ; 2ft d2ft Search for a string /, ? Search ‘/’ and ‘?’ No string argument, n/N
20
Copy and Move Text Yank (y) Put (p/P) y (enter), Y, yy
Copy text into a General-Purpose buffer Put (p/P) Copy text from the General-Purpose buffer Deleted text is also in the General-Purpose buffer
21
Read and Write Files Exit (zz) Read files Write to files
[address]:r [filename] :r hello Write to files [address]:w [filename] :1,5w! :w >> filename
22
Execute Shell Commands in vim
Spawn a new shell :sh ps -f Return to vim: CTRL+D, exit Directly execute :!command :!ls !!cat hello
23
Execute Shell Commands in vim
Directly execute Use parts of the file as standard input vim months :1,5!sort
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.