您的位置:首页 > 运维架构 > Linux

对Linux命令进一步学习vim(二)

2016-03-14 11:39 906 查看
今天,进一步学习Linux相关的命令,可能会有重复的地方,但学习本来就是不断重复的过程。故作小记!

1.安装了:vim ,,,一款Linux爱好者经常用到的ide

sudo apt-get install vim

root@wuheng-virtual-machine:/var/www/html# ls
a.txt demo1 index.html phpmyadmin wh.tar.gz
root@wuheng-virtual-machine:/var/www/html# vi a.txt #####使用vim编辑器打开a.txt文件,,,vim a.txt亦可。

E325: ATTENTION
Found a swap file by the name ".a.txt.swp"
owned by: root dated: Sun Mar 13 19:41:51 2016
file name: /var/www/html/a.txt
modified: YES
user name: root host name: wuheng-virtual-machine
process ID: 3529 (still running)
While opening file "a.txt"
dated: Sun Mar 13 20:04:42 2016
NEWER than swap file!

(1) Another program may be editing the same file. If this is the case,
be careful not to end up with two different instances of the same
file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r a.txt"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".a.txt.swp"
to avoid this message.

Swap file ".a.txt.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: #####选择你要对该文件的访问方式

1-1.历史命令

以:和/开头的命令都有历史纪录,可以首先键入:或/然后按上下箭头来选择某个历史命令。

~
~
~
:q!

1-2.直接在文本内容上进行编辑操作。

1-3:编辑完成后,按“Esc”键,退出当前的编辑,按组合键(“shift+:”),然后使用退出命令

:wq 保存并退出

ZZ 保存并退出

:q! 强制退出并忽略所有更改

:e! 放弃所有修改,并打开原来文件。

1-4,vim模式

正常模式(按Esc或Ctrl+[进入) 左下角显示文件名或为空
插入模式(按i键进入) 左下角显示--INSERT--
可视模式(不知道如何进入) 左下角显示--VISUAL--

1-5,插入命令

i 在当前位置生前插入

I 在当前行首插入

a 在当前位置后插入

A 在当前行尾插入

o 在当前行之后插入一行

O 在当前行之前插入一行
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: