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

本文详细记录了Linux环境下安装Vim编辑器、使用Linux命令进行基本操作及在Vim中进行文本编辑的方法,包括历史命令的使用、直接编辑文本、编辑命令的应用、Vim模式切换和插入命令等。

今天,进一步学习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 在当前行之前插入一行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值