Mastering vi Editor in Unix: Essential Commands and Techniques
E N D
Presentation Transcript
Unit 3 – The vi editor • Understand the importance of vi in Unix • Be able to use vi • Create and change text, copy and paste • Search for patterns, global multiple changes • Read and write portions of files • Edit multiple files • Cut and past from other text displays
Importance of vi • Importance of vi and its variants in Unix • Available in any Unix system even if the system is running at low level without X-windows, vi does not need a window, it can work in the terminal display • Vi is a powerful full screen editor • Old style, vim • Arrow keys sometimes work, sometimes don't, you have to find out. Sometimes you have to leave input mode when navigating, sometimes don't • You should know a modicum of vi
Using vi • Input mode • Command mode • Switching between these two • Commands: i o yy p P x dd • Repeat last command
More vi commands • Search for patterns • Search and replace patterns • Save file • Quit vi • Commands: s w q
More vi commands • Read and write portions of files • Join lines • Edit multiple files • Commands: r w J e n