Text Editors: Emacs and Vim Commands

text editors n.w
1 / 25
Embed
Share

Explore the functionalities of Emacs and Vim text editors through a detailed guide on cursor movement, basic operations, and essential commands like saving, opening, and searching within files. Learn key combinations for efficient text editing and manipulation in Unix environments.

  • Text Editors
  • Emacs
  • Vim
  • Unix
  • Commands

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Text Editors Vim Emacs (Chapter 6) (Chapter 7) John Carelli,Instructor Kutztown University carelli@kutztown.edu 1

  2. Unix Text Editors There are many text editors available in Unix Source: Reddit 2 CSC252: John Carelli

  3. Two Popular Choices Emacs and Vim Emacs non-modal no separate editing mode commands make use of key combinations (cntl, alt, ) slower, complex, extensible Vim vi improved inherently modal command vs. text entry modes faster, simpler Source: Dr. Lisa Frye 3 CSC252: John Carelli

  4. Basic operation Emacs to enter text, just start typing navigate with movement commands key combinations (using cntl, alt, esc, ) additional commands to copy/paste, etc. Vim to enter text, first enter insert mode enter text return to command mode with esc key in command mode navigate, copy/paste, etc. basic commands are one character 4 CSC252: John Carelli

  5. EMACS some basic commands 5 CSC252: John Carelli

  6. Emacs Cursor Movement CTRL-f CTRL-b ESC-f ESC-b CTRL-a CTRL-e CTRL-p CTRL-n ESC-a ESC-e CTRL-v ESC-v ESC-< ESC-> forward one character Back one character Forward one word Back one word Beginning of current line End of current line Previous line Next line Beginning of current sentence End of current sentence Forward one page Back one page Beginning of buffer End of buffer Source: Dr. Lisa Frye 6 CSC252: John Carelli

  7. CTRL-x CTRL-s Save file CTRL-x CTRL-c Exit editor CTRL-x CTRL f Open a file CTRL-h Help CTRL-_ Undo 7 CSC252: John Carelli Source: Dr. Lisa Frye

  8. CTRL-k Delete line from cursor to end and puts it in kill ring (buffer) Yank kill ring contents to current position CTRL-y CTRL-s Search forward for word CTRL-_r Search backward for word 8 CSC252: John Carelli Source: Dr. Lisa Frye

  9. Esc-x set-mark also works;set Mark to current position CTRL-@ ESC-w Copy region to kill ring (buffer) CTRL-w Cut region and paste in kill ring (buffer) 9 CSC252: John Carelli Source: Dr. Lisa Frye

  10. CTRL-x CTRL-b Open a new window CTRL-x b Switch to named window CTRL-x 2 Split window into 2 horizontally CTRL-x 3 Split window into 2 vertically CTRL-x o Switch to the other window CTRL-x 0 Close current window 10 CSC252: John Carelli Source: Dr. Lisa Frye

  11. Esc-l Esc-u Esc-c CTRL-x CTRL-l CTRL-x CTRL-u Convert word to lowercase Convert word to uppercase Convert word to initial caps Convert region to lowercase Convert region to uppercase 11 CSC252: John Carelli Source: Dr. Lisa Frye

  12. CTRL-x ( Start recording a macro CTRL-x ) Stop recording a macro CTRL-e Run the macro Esc-# CTRL-e Run the macro # times 12 CSC252: John Carelli Source: Dr. Lisa Frye

  13. Vim some basic commands 13 CSC252: John Carelli

  14. Vim Modes Typically starts in command mode keystrokes are interpreted as commands edit, navigate, etc. Some Insert Commands Insert mode enter with insert command esckey return to command mode i before current location a after current location I at beginning of line A at end of line o new line below O New line above Note: vim is based on vi, which was based on ed (more on ed here) Source: Dr. Lisa Frye 14 CSC252: John Carelli

  15. Vim Cursor Movement l forward one character h Back one character w Forward one word b Back one word ^ Beginning of current line $ Enter End of current line Beginning of next line k Character above j Character below e End of word CTRL-f CTRL-b Forward one page Back one page 15 CSC252: John Carelli

  16. :w Save file :wq (or ZZ) Save file and exit :q! Exit without saving :e name Open a file :help Help u Undo r redo 16 CSC252: John Carelli Source: Dr. Lisa Frye

  17. Delete line from cursor to end and put it in buffer Paste buffer contents to current position d$ p /word Search forward for word ?word Search backward for word 17 CSC252: John Carelli Source: Dr. Lisa Frye

  18. ma set Mark a to current position (can use any letter to set multiple marks) c a Copy lines from present location to the mark into the buffer Delete lines from present location to the mark and store in the buffer d a v Highlight a region by moving the cursor (subsequent commands work on the highlighted text) esc Remove highlighting 18 CSC252: John Carelli Source: Dr. Lisa Frye

  19. CTRL-w CTRL-s (or :sp) CTRL-w CTRL-w Split window into 2 horizontally Cycle through open windows CTRL-w CTRL-v Split window into 2 vertically :q Close current window 19 CSC252: John Carelli Source: Dr. Lisa Frye

  20. ~ Switch case u Make highlighted text lowercase U Make highlighted text uppercase 20 CSC252: John Carelli Source: Dr. Lisa Frye

  21. qa Start recording macro a (can use any letter to record multiple macros) Stop recording a macro q @a Run macro a @@ Rerun last macro #@a Run the macro # times 21 CSC252: John Carelli Source: Dr. Lisa Frye

  22. Initialization files Customize editor behavior located in home directory .emacs file .vimrc file Key Mappings Colors Default behavior etc Source: Dr. Lisa Frye 22 CSC252: John Carelli

  23. Another popular choice - Nano A simple text editor that comes with Linux Shortcuts for common commands are available at the bottom of the screen (including help) A tutorial: https://www.howtogeek.com/howto/42980/the- beginners-guide-to-nano-the-linux-command-line- text-editor/ CSC252: John Carelli

  24. Nano Commands Basic commands are displayed at the bottom of the screen They are a combination of Cntl or Alt (on a PC) and a character ^-X means Cntl-X M-U means Alt-U Some commands ^O write out (save the file being edited) ^X exit the editor M-U undo the last change CSC252: John Carelli

  25. Nano Example CSC252: John Carelli

More Related Content