Appendix A. Using vi or Vim Editors

IN THIS APPENDIX

  • Using the vi editor

  • Starting/quitting the vi editor

  • Moving around in vi

  • Changing and deleting text

  • Using Ex commands

  • Using visual mode

Although easy-to-use graphical text editors (such as gedit and kedit) are readily available with Linux, most power users still use vi or Emacs to edit text files. Besides the fact that vi and Emacs will work from any shell (no GUI required), they offer other advantages such as your hands never having to leave the keyboard and integration with useful utilities. And unlike GUI editors, text-based editors are usable over slow Internet connections such as dial-up or satellite.

This appendix focuses on features of the vi editor that can not only help you with basic editing, but also help you do some advanced text manipulation. We chose to cover vi rather than Emacs because vi is more universal and leaner, and also because vi keyboard shortcuts only require two arms. Because many Linux systems use the Vim (Vi IMproved) editor in place of the older vi editor, the descriptions in this appendix are extended to cover Vim as well. Some features in Vim that are not in vi include multiple undo levels, syntax highlighting, and online help.

Note

If you have never used vi or Vim before, try out the tutor that comes with the vim-enhanced package. Run the vimtutor command and follow the instructions to step through many of the key features of vi and Vim.

Starting and Quitting the vi Editor

If you want to experiment with using ...

Get Fedora® Linux® TOOLBOX: 1000+ Commands for Fedora, CentOS, and Red Hat® Power Users now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.