5.1 vim introduction 5.2 vim color display and moving the cursor 5.3 moving the cursor in vim normal mode 5.4 copying, cutting and pasting in vim normal mode

1. Introduction to vim

  • vim is an upgraded version of vi
  • vim is displayed with color
  • vim installation method yum install -y vim-enhanced
  • There are three modes in vim: general mode, editing mode, command mode. Why should we learn the vim editor? There are a lot of text editors under the command line interface of Linux. For example, Emacs, pico, nano, joe and vim are often heard. vim can be seen as an advanced version of vi. Why do we have to learn vim? There are several reasons: <br/> 1. All Unix like systems have built-in vi text editors, and other text editors may not exist. 2. Many software editing interfaces will actively call vi. 3.vim has the ability of program editing, and can actively identify the correctness of grammar by font color, which is convenient for program design. The procedure is simple and the editing speed is fast.

2. vim color display and move cursor

  • .conf
  • .sh
  • The configuration files under the specified directory /etc/ were previously displayed in color in these common configuration files or shell script files

3. Move the cursor in vim normal mode

Ctrl+f:					屏幕向下移动一页,相当于PageDown按键。
Ctrl+b:					屏幕向上移动一页,相当于PageUp按键。
0或功能键Home或^:		移动到这一行的最前面字符处。
$或功能键End:			移动到这一行的最后面字符处。
G:						移动到这个文件的最后一行。			//注意大写
gg:						移动到这个文件的第一行,相当于1G		//小写
nG:						移动到第n行
h或者向左的方向键:			光标向左移动一个字符
l(小写)或者向右的方向键	光标向右移动一个字符
k或者向上的方向键			光标向上移动一个字符
j或者向下的方向键			光标向下移动一个字符

4. Copy and paste in normal mode

x,X		x表示向后删除一个字符,X表示向前删除一个字符
nx		向后删除n个字符
dd		删除/剪切光标所在的那一行
ndd		删除/剪切光标所在行之后的n行
yy		复制光标所在行
nyy		从光标所在行开始,向下复制n行
p		从光标所在行开始,向下粘贴已经复制或者粘贴的内容
P		从光标所在行开始,向上粘贴已经复制或者粘贴的内容
u		撤消上一步操作
v		按v后移动光标会选中指定字符,然后可以实现复制、粘贴等操作

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325473227&siteId=291194637