Update and rename sources/tech/20131227 Vim Keyboard Shortcuts Cheatsheet - part2.md to translated/tech/20131227 Vim Keyboard Shortcuts Cheatsheet - part2.md

下载链接怪怪的,我这边好像下载不了。
This commit is contained in:
martin qi 2017-01-22 23:14:20 +09:00 committed by GitHub
parent adf2db53ce
commit 57864cd72c
2 changed files with 215 additions and 218 deletions

View File

@ -1,218 +0,0 @@
Martin translating...
Vim Keyboard Shortcuts Cheatsheet
============================================================
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2013/12/vim-shortcut-cheatsheet-featured.jpg "Vim Keyboard Shortcuts Cheatsheets")
This article is part of the [VIM User Guide][12] series:
* [The Beginners Guide to Start Using Vim][3]
* Vim Keyboard Shortcuts Cheatsheet
* [5 Vim Tips and Tricks for Experienced Users][4]
* [3 Useful VIM Editor Tips and Tricks for Advanced Users][5]
The Vim editor is a command-line based tool thats an enhanced version of the venerable vi editor. Despite the abundance of graphical rich text editors, familiarity with Vim will help every Linux user — from an experienced system administrator to a newbie Raspberry Pi user.
The light-weight editor is a very powerful tool. In the hands of an experienced operator, it can do wonders. Besides regular text editing functions, the editor also supports advanced features such as find & replace based on regular expressions and encoding conversion as well as programming features such as syntax highlighting and code folding.
One important thing to note when using Vim, is that the function of a key depends on the “mode” the editor is in. For example, pressing the alphabet “j” will move the cursor down one line in the “command mode”. Youll have to switch to the “insert mode” to make the keys input the character they represent.
Heres a cheatsheet to help you get the most out of Vim.
### Main
| Shortcut Keys | Function |
| --- | --- |
| Escape key | Gets out of the current mode into the “command mode”. All keys are bound of commands. |
| i | “Insert mode” for inserting text. Keys behave as expected. |
| : | “Last-line mode” where Vim expects you to enter a command such as to save the document. |
### Navigation keys
| Shortcut Keys | Function |
| --- | --- |
| h | moves the cursor one character to the left. |
| j or Ctrl + J | moves the cursor down one line. |
| k or Ctrl + P | moves the cursor up one line. |
| l | moves the cursor one character to the right. |
| 0 | moves the cursor to the beginning of the line. |
| $ | moves the cursor to the end of the line. |
| ^ | moves the cursor to the first non-empty character of the line |
| w | move forward one word (next alphanumeric word) |
| W | move forward one word (delimited by a white space) |
| 5w | move forward five words |
| b | move backward one word (previous alphanumeric word) |
| B | move backward one word (delimited by a white space) |
| 5b | move backward five words |
| G | move to the end of the file |
| gg | move to the beginning of the file. |
### Navigate around the document
| Shortcut Keys | Function |
| --- | --- |
| ( | jumps to the previous sentence |
| ) | jumps to the next sentence |
| { | jumps to the previous paragraph |
| } | jumps to the next paragraph |
| [[ | jumps to the previous section |
| ]] | jumps to the next section |
| [] | jump to the end of the previous section |
| ][ | jump to the end of the next section |
### Insert text
| Shortcut Keys | Function |
| --- | --- |
| a | Insert text after the cursor |
| A | Insert text at the end of the line |
| i | Insert text before the cursor |
| o | Begin a new line below the cursor |
| O | Begin a new line above the cursor |
### Special inserts
| Shortcut Keys | Function |
| --- | --- |
| :r [filename] | Insert the file [filename] below the cursor |
| :r ![command] | Execute [command] and insert its output below the cursor |
### Delete text
| Shortcut Keys | Function |
| --- | --- |
| x | delete character at cursor |
| dw | delete a word. |
| d0 | delete to the beginning of a line. |
| d$ | delete to the end of a line. |
| d) | delete to the end of sentence. |
| dgg | delete to the beginning of the file. |
| dG | delete to the end of the file. |
| dd | delete line |
| 3dd | delete three lines |
### Simple replace text
| Shortcut Keys | Function |
| --- | --- |
| r{text} | Replace the character under the cursor with {text} |
| R | Replace characters instead of inserting them |
### Copy/Paste text
| Shortcut Keys | Function |
| --- | --- |
| yy | copy current line into storage buffer |
| ["x]yy | Copy the current lines into register x |
| p | paste storage buffer after current line |
| P | paste storage buffer before current line |
| ["x]p | paste from register x after current line |
| ["x]P | paste from register x before current line |
### Undo/Redo operation
| Shortcut Keys | Function |
| --- | --- |
| u | undo the last operation. |
| Ctrl+r | redo the last undo. |
### Search and Replace keys
| Shortcut Keys | Function |
| --- | --- |
| /search_text | search document for search_text going forward |
| ?search_text | search document for search_text going backward |
| n | move to the next instance of the result from the search |
| N | move to the previous instance of the result |
| :%s/original/replacement | Search for the first occurrence of the string “original” and replace it with “replacement” |
| :%s/original/replacement/g | Search and replace all occurrences of the string “original” with “replacement” |
| :%s/original/replacement/gc | Search for all occurrences of the string “original” but ask for confirmation before replacing them with “replacement” |
### Bookmarks
| Shortcut Keys | Function |
| --- | --- |
| m {a-z A-Z} | Set bookmark {a-z A-Z} at the current cursor position |
| :marks | List all bookmarks |
| `{a-z A-Z} | Jumps to the bookmark {a-z A-Z} |
### Select text
| Shortcut Keys | Function |
| --- | --- |
| v | Enter visual mode per character |
| V | Enter visual mode per line |
| Esc | Exit visual mode |
### Modify selected text
| Shortcut Keys | Function |
| --- | --- |
| ~ | Switch case |
| d | delete a word. |
| c | change |
| y | yank |
| > | shift right |
| < | shift left |
| ! | filter through an external command |
### Save and quit
| Shortcut Keys | Function |
| --- | --- |
| :q | Quits Vim but fails when file has been changed |
| :w | Save the file |
| :w new_name | Save the file with the new_name filename |
| :wq | Save the file and quit Vim. |
| :q! | Quit Vim without saving the changes to the file. |
| ZZ | Write file, if modified, and quit Vim |
| ZQ | Same as :q! Quits Vim without writing changes |
### Download VIM Keyboard Shortcuts Cheatsheet
Cant get enough of this? We have prepared a downloadable cheat sheet for you so you can access to it when you need it.
[Download it here!][14]
--------------------------------------------------------------------------------
via: https://www.maketecheasier.com/vim-keyboard-shortcuts-cheatsheet/
作者:[Himanshu Arora][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.maketecheasier.com/author/himanshu/
[1]:https://www.maketecheasier.com/author/mayank/
[2]:https://www.maketecheasier.com/vim-keyboard-shortcuts-cheatsheet/#comments
[3]:https://www.maketecheasier.com/start-with-vim-linux/
[4]:https://www.maketecheasier.com/vim-tips-tricks-for-experienced-users/
[5]:https://www.maketecheasier.com/vim-tips-tricks-advanced-users/
[6]:https://www.maketecheasier.com/category/linux-tips/
[7]:http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.maketecheasier.com%2Fvim-keyboard-shortcuts-cheatsheet%2F
[8]:http://twitter.com/share?url=https%3A%2F%2Fwww.maketecheasier.com%2Fvim-keyboard-shortcuts-cheatsheet%2F&text=Vim+Keyboard+Shortcuts+Cheatsheet
[9]:mailto:?subject=Vim%20Keyboard%20Shortcuts%20Cheatsheet&body=https%3A%2F%2Fwww.maketecheasier.com%2Fvim-keyboard-shortcuts-cheatsheet%2F
[10]:https://www.maketecheasier.com/locate-system-image-tool-in-windows-81/
[11]:https://www.maketecheasier.com/create-system-image-in-windows8/
[12]:https://www.maketecheasier.com/series/vim-user-guide/
[13]:https://support.google.com/adsense/troubleshooter/1631343
[14]:http://www.maketecheasier.com/cheatsheet/vim-keyboard-shortcuts-cheatsheet/

View File

@ -0,0 +1,215 @@
Vim 快捷键速查表
============================================================
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2013/12/vim-shortcut-cheatsheet-featured.jpg "Vim Keyboard Shortcuts Cheatsheets")
本文是 [VIM 用户指南][12] 系列的其中一篇:
* [Vim 初学者入门指南][3]
* Vim 快捷键速查表
* [5 个针对有经验用户的 Vim 实用技巧][4]
* [3 个针对高级用户的 Vim 编辑器实用技巧][5]
Vim 编辑器是一个基于命令行的工具,传奇编辑器 vi 的增强版。尽管图形界面的富文本编辑有很多,但是熟悉 Vim 对于每一位 Linux 的使用者都能有所帮助——无论你是经验丰富的系统管理员,还是刚上手树莓派的新手用户。
这个轻量级的编辑器是个非常强大的工具。在有经验的使用者手中,她能完成不可思议的任务。除了常规的文本编辑功能以外,她还支持一些进阶特性。例如,基于正则表达式的搜索和替换,编码转换,以及语法高亮、代码折叠等的编程特性。
使用 Vim 时有一个非常重要的一点需要注意那就是键的功能取决于编辑器当前的“模式”。例如在“普通模式”输入字母“j”时光标会向下移动一行。而当你在“插入模式”下输入字符则只是正常的文字录入。
下面就是速查表,以便于你充分利用 Vim。
### 基本操作
| 快捷键 | 功能 |
| --- | --- |
| Esc | 从当前模式转换到“普通模式”。所有的键对应着命令。 |
| i | “插入模式”用于插入文字。回归按键的本职工作。 |
| : | “命令行模式” Vim 希望你输入类似于保存该文档命令的地方。 |
### 方向键
| 快捷键 | 功能 |
| --- | --- |
| h | 光标向左移动一个字符 |
| j or Ctrl + J | 光标向下移动一行 |
| k or Ctrl + P | 光标向上移动一行 |
| l | 光标向右移动一个字符 |
| 0 | 移动光标至本行开头 |
| $ | 移动光标至本行末尾 |
| ^ | 移动光标至本行第一个非空字符处 |
| w | 向前移动一个词 (上一个字母和数字之后) |
| W | 向前移动一个词 (空格分隔即为词) |
| 5w | 向前移动五个词 |
| b | 向后移动一个词 (下一个字母和数字之前) |
| B | 向后移动一个词 (空格分隔即为词) |
| 5b | 向后移动五个词 |
| G | 移动至文件末尾 |
| gg | 移动至文件开头 |
### 浏览文档
| 快捷键 | 功能 |
| --- | --- |
| ( | 跳转到上一句 |
| ) | 跳转到下一句 |
| { | 跳转到上一段 |
| } | 跳转到下一段 |
| [[ | 跳转到上一部分 |
| ]] | 跳转到下一部分 |
| [] | 跳转到上一部分的末尾 |
| ][ | 跳转到上一部分的开头 |
### 插入文本
| 快捷键 | 功能 |
| --- | --- |
| a | 在光标后插入文本 |
| A | 在行末插入文本 |
| i | 在光标前插入文本 |
| o | 在光标下方新开一行 |
| O | 在光标上方新开一行 |
### 特殊插入
| 快捷键 | 功能 |
| --- | --- |
| :r [filename] | 在光标下方插入文件 [filename] |
| :r ![command] | 执行命令 [command] 并将输出插入至光标下方 |
### 删除文本
| 快捷键 | 功能 |
| --- | --- |
| x | 删除光标处字符 |
| dw | 删除一个词 |
| d0 | 删至行首 |
| d$ | 删至行末 |
| d) | 删至句末 |
| dgg | 删至文件开头 |
| dG | 删至文件末尾 |
| dd | 删除该行 |
| 3dd | 删除三行 |
### 简单替换文本
| 快捷键 | 功能 |
| --- | --- |
| r{text} | 将光标处的字符替换成 {text} |
| R | 输入的字符将替换原有的字符 |
### 复制/粘贴文本
| 快捷键 | 功能 |
| --- | --- |
| yy | 复制当前行至存储缓冲区 |
| ["x]yy | 复制当前行至寄存器 x |
| p | 在当前行之后粘贴存储缓冲区中的内容 |
| P | 在当前行之前粘贴存储缓冲区中的内容 |
| ["x]p | 在当前行之后粘贴寄存器 x 中的内容 |
| ["x]P | 在当前行之前粘贴寄存器 x 中的内容 |
### 撤销/重做操作
| 快捷键 | 功能 |
| --- | --- |
| u | 撤销最后的操作 |
| Ctrl+r | 重做最后撤销的操作 |
### 搜索和替换
| 快捷键 | 功能 |
| --- | --- |
| /search_text | 检索文档,定位到 search_text 前 |
| ?search_text | 检索文档,定位到 search_text 后 |
| n | 移动到检索结果的后一句 |
| N | 移动到检索结果的前一句 |
| :%s/original/replacement | 检索第一个 “original” 字符串并将其替换成 “replacement” |
| :%s/original/replacement/g | 检索并将所有的 “original” 替换为 “replacement” |
| :%s/original/replacement/gc | 检索出所有的 “original” 字符串,但在替换成 “replacement” 前,先询问是否替换 |
### 书签
| 快捷键 | 功能 |
| --- | --- |
| m {a-z A-Z} | 在当前光标位置设置书签 {a-z A-Z} |
| :marks | 列出所有书签 |
| `{a-z A-Z} | 跳转到书签 {a-z A-Z} |
### 选择文本
| 快捷键 | 功能 |
| --- | --- |
| v | 进入逐字可视模式 |
| V | 进入逐行可视模式 |
| Esc | 退出可视模式 |
### 改动选中文本
| 快捷键 | 功能 |
| --- | --- |
| ~ | 切换大小写 |
| d | 删除一个词 |
| c | 变更 |
| y | 复制 |
| > | 右移 |
| < | 左移 |
| ! | 通过外部命令进行过滤 |
### 保存并退出
| 快捷键 | 功能 |
| --- | --- |
| :q | 退出 Vim如果文件已被修改将退出失败 |
| :w | 保存文件 |
| :w new_name | 用 new_name 作为文件名保存文件 |
| :wq | 保存文件并退出 Vim |
| :q! | 退出 Vim不保存文件改动 |
| ZZ | 退出 Vim如果文件被改动过保存改动内容 |
| ZQ | 与 :q! 相同,退出 Vim不保存文件改动 |
### 下载 VIM 快捷键速查表
仅仅是这样是否还不足以满足你?别担心,我们已经为你整理好了一份下载版的速查表,以备不时之需。
[点此下载(英文)][14]
--------------------------------------------------------------------------------
via: https://www.maketecheasier.com/vim-keyboard-shortcuts-cheatsheet/
作者:[Himanshu Arora][a]
译者:[martin2011qi](https://github.com/martin2011qi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.maketecheasier.com/author/himanshu/
[1]:https://www.maketecheasier.com/author/mayank/
[2]:https://www.maketecheasier.com/vim-keyboard-shortcuts-cheatsheet/#comments
[3]:https://www.maketecheasier.com/start-with-vim-linux/
[4]:https://www.maketecheasier.com/vim-tips-tricks-for-experienced-users/
[5]:https://www.maketecheasier.com/vim-tips-tricks-advanced-users/
[6]:https://www.maketecheasier.com/category/linux-tips/
[7]:http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.maketecheasier.com%2Fvim-keyboard-shortcuts-cheatsheet%2F
[8]:http://twitter.com/share?url=https%3A%2F%2Fwww.maketecheasier.com%2Fvim-keyboard-shortcuts-cheatsheet%2F&text=Vim+Keyboard+Shortcuts+Cheatsheet
[9]:mailto:?subject=Vim%20Keyboard%20Shortcuts%20Cheatsheet&body=https%3A%2F%2Fwww.maketecheasier.com%2Fvim-keyboard-shortcuts-cheatsheet%2F
[10]:https://www.maketecheasier.com/locate-system-image-tool-in-windows-81/
[11]:https://www.maketecheasier.com/create-system-image-in-windows8/
[12]:https://www.maketecheasier.com/series/vim-user-guide/
[13]:https://support.google.com/adsense/troubleshooter/1631343
[14]:http://www.maketecheasier.com/cheatsheet/vim-keyboard-shortcuts-cheatsheet/