Differences
This shows you the differences between two versions of the page.
linux_wiki:create_and_edit_text_files [2016/02/29 22:50] billdozor [Insert Mode] |
linux_wiki:create_and_edit_text_files [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Create And Edit Text Files ====== | ||
- | |||
- | **General Information** | ||
- | |||
- | About this page/ | ||
- | |||
- | ---- | ||
- | |||
- | ====== Linux Text Editors ====== | ||
- | |||
- | * emacs => older text editor, not always on a system | ||
- | * nano => very simple edtior, not always on a system | ||
- | * vi/vim => vi always on the system, vim sometimes on a system | ||
- | * **For this reason, learn vi/vim.** | ||
- | |||
- | ---- | ||
- | |||
- | ===== vi/vim ===== | ||
- | |||
- | vi or vim will almost always be installed on a Linux distro, so it is the best to learn. | ||
- | |||
- | Create new file " | ||
- | <code bash> | ||
- | vi file1 | ||
- | </ | ||
- | |||
- | * Command Mode => Cannot type into the file, used for movement/ | ||
- | * Insert Mode => Type in this mode | ||
- | * Ex Mode => Searching, Saving, Quiting, and Changing Vi's options | ||
- | |||
- | ---- | ||
- | |||
- | ==== Command Mode ==== | ||
- | |||
- | Movement | ||
- | * i => enter Insert Mode | ||
- | * h => move left | ||
- | * j => move down | ||
- | * k => move up | ||
- | * l => move right | ||
- | * G => goto last line in file | ||
- | * 1G => goto first line in file | ||
- | |||
- | Editing | ||
- | * yy => yank line (copy) | ||
- | * p => paste before current line | ||
- | * P => paste after current line | ||
- | * u => undo last change | ||
- | * dd => delete line | ||
- | * 5dd => delete 5 lines | ||
- | * dw => delete current word | ||
- | * cw => delete current word and enter insert mode (change word) | ||
- | * cc => delete current line and enter insert mode | ||
- | |||
- | ---- | ||
- | |||
- | ==== Insert Mode ==== | ||
- | |||
- | * Esc => leave Insert mode, enter Command Mode | ||
- | |||
- | ---- | ||
- | |||
- | ==== Ex Mode ==== | ||
- | |||
- | * :q => quit | ||
- | * :w => write changes (save) | ||
- | * :wq => write (save) and quit | ||
- | * :q! => quit without saving changes | ||
- | * :%s/dog/cat => replace first occurance of " | ||
- | * : | ||
- | * :! => run shell commands from vi | ||
- | * :r oldfile => copy contents of oldfile into current file being edited | ||
- | * :e file1.txt => load file1.txt into the editor (only if current file being edited has been saved) | ||
- | |||
- | ---- | ||
- | |||