Emergency vi (vim tutorial)
来源:互联网 发布:ipad 抓包淘宝旧版本 编辑:程序博客网 时间:2024/06/03 21:55
Emergency vi (vim tutorial)
vi is one of unix's fsckup. Sometimes in a emergency situation you are forced to deal with vi, and fscking unix admins refuse to install emacs. Here's your help.
vi man- To open a file named “myfile.txt”, type in the shell prompt:
vi myfile.txt
- To quit without saving, press: 【Esc : q ! Enter ↵】
- To save current file, press: 【Esc : w Enter ↵】
- To quit vi, type: 【Esc : q Enter ↵】
- Use arrow keys to move the cursor.
- page up: 【Ctrl+b】
- page down: 【Ctrl+f】
To insert text, move your cursor to the right place, then press i, then type your text. After you are done, type Esc to exit the insertion mode.
To delete text, move cursor to the right place and press x. (if x is inserted, that means you forgot to exit the insert mode. Type Esc to exit insertion mode. Type u to undo.)
When something doesn't work, or if you accidentally typed something and have no idea what is going on, try press Esc, then type u for undo. If a cat jumped onto your keyboard and you cannot exit vi, type the shell suspend command 【Ctrl+z】, which should get you back on the unix command prompt, then you can kill. (by first find out the pid by ps auwwx | grep vi
, then kill -9 pid
).
Congratulation! You've learned emergency vi.
It may be confusing, but with the above you can edit any text files with vi.
Installing vim
By default, the vi in Ubuntu 12.04 (as of 2013-02-11) is “vim.tiny”, a very basic vi-like vim. You should install full vim. For how to install and other detail, see: Ubuntu Linux: vim Location and Versions.
Basic vi Commands
Remember, in vi, it has modes. At any one time, you are either in command mode or text insertion mode. To go to the command mode, just press Esc. To go into editing mode, press i.
Goto Insertion Mode
Undo & Redo
Cursor Movement
Deleting Text
Copy & Paste
How to copy?
press 【v】 at the beginning of copy/cut position, then move cursor, then press 【d】 to cut, 【y】 to copy.
Note that when you delete a word or many words, the word is automatically put into the clipboard.
Search
Find & Replace
Comment/Uncomment Block
How to comment/uncomment a text block?
press 【Ctrl+v】 (called “visual block”), move cursor to select, then press 【I # Esc】 to insert #
to all lines in the block.
To uncomment a block, do the same except just press 【x】 to kill a char.
Syntax Coloring
Line Numbers
Advanced Topics
【gg】beginning of file【G】end of file【dG】delete from current line to end of fileOpening File
【:tabe path】opening file【gf】open path under cursorVim Init Files
default vim init file path: ~/.vimrc
vim -u filename
→ start vim with a different init file.vim -u NONE
→ start vim without init.vim -u NORC
→ start vim without init but with plugin.
How to Remap the Escape Key?
Vim: How to Remap the Escape Key?
misc notes
How to refresh buffer?
Type 【:e】
- on vi Keybinding vs Emacs Keybinding
- History of Emacs & vi Keys (Keyboard Influence on Keybinding Design)
- Emacs Basics
- Arrow Keys Layout Efficiency: vi's {H J K L} vs Inverted T {I J K L}
- Text Editor's Cursor Movement Behavior (emacs, vi, Notepad++)
- vi, vim: 3 Decades Pile of History
- Emergency vi (vim tutorial)
- Graphical vi-vim Cheat Sheet and Tutorial
- [ZZ] Graphical vi-vim Cheat Sheet and Tutorial
- Linux vi and vim editor: Tutorial and advanced features
- Vi and Vim Macro Tutorial: How To Record and Play
- vim tutorial
- VIM Tutorial
- vim tutorial
- vi/vim
- Vim & Vi
- vi & vim
- vi & vim
- vi & vim
- Vim/Vi
- vim/vi
- vim/vi
- vi/vim
- vi/vim
- Unicode下CString转UTF-8,再转UTF-8的%形式
- 搜索引擎系列 -lucene简介 创建索引和搜索初步步骤
- JavaScript 基础(一)
- 明道学院——《揭开CRM部署的隐藏成本》
- listView单选实现(二)
- Emergency vi (vim tutorial)
- 窗口、视口、屏幕显示详解--计算机绘图基本功
- kmp算法看的3篇博客(未整理)
- Android读取/dev/graphics/fb0 屏幕截图
- Oracle11g安装图解
- valgrind的使用
- Longest Consecutive Sequence
- Netty5源码分析(七) -- 异步执行Future和Promise
- .net CMS汇总