Linux-centos6.5-(第三篇)文件编辑

目录

 

文件编辑命令

打卡文件模式:

移动:

翻页

删除操作:

撤销操作

复制操作

显示行号


文件编辑命令

命令:vi

--                         Only file names after this

   -v                           Vi mode (like "vi")

   -e                           Ex mode (like "ex")

   -s                           Silent (batch) mode (only for "ex")

   -y                           Easy mode (like "evim", modeless)

   -R                          Readonly mode (like "view")

   -Z                           Restricted mode (like "rvim")

   -m                         Modifications (writing files) not allowed

   -M                         Modifications in text not allowed

   -b                           Binary mode

   -C                          Compatible with Vi: 'compatible'

   -N                          Not fully Vi compatible: 'nocompatible'

   -V[N][fname]               Be verbose [level N] [log messages to fname]

   -n                           No swap file, use memory only

   -r                           List swap files and exit

   -r (with file name)      Recover crashed session

   -L                           Same as -r

   -T <terminal>     Set terminal type to <terminal>

   -u <vimrc>           Use <vimrc> instead of any .vimrc

   --noplugin            Don't load plugin scripts

   -p[N]            Open N tab pages (default: one for each file)

   -o[N]            Open N windows (default: one for each file)

   -O[N]           Like -o but split vertically

   +                            Start at end of file

   +<lnum>              Start at line <lnum>

   --cmd <command>     Execute <command> before loading any vimrc file

   -c <command>            Execute <command> after loading the first file

   -S <session>                 Source file <session> after loading the first file

   -s <scriptin>       Read Normal mode commands from file <scriptin>

   -w <scriptout>   Append all typed commands to file <scriptout>

   -W <scriptout>  Write all typed commands to file <scriptout>

   -h  or  --help   Print Help (this message) and exit

   --version              Print version information and exit

 

打卡文件模式:

vi fileName #打卡文件,如果文件不存在,则在当前文件下自动创建该文件。

vi +num pathtoFileName #打开文件并将光标移动到第num行。

进入编辑模式:打开文件后双击a或者输入i 进入编辑模式。

进入命令模式:按esc 进入。

在命令模式下按:wq保存并退出文件,:q退出不保存文件。

命令模式下常用命令:

移动:

k      向上移动

j   向下移动

h  向左移动

l   向右移动

(以上四个根据键盘位置记忆,多操作便成习惯)

^  移动到行首

$  移动到行尾

第n行 G(双击g)跳转到第n行

 

翻页

Ctrl+F 向前翻页(change forward 巧记,向前翻)

Ctrl+B 向后翻页(change back)

Ctrl+U 向上翻半页 (change to Up)

Ctrl+D 向下翻半页 (change to Down)

 

删除操作:

x 删除光标位置的字符

dd 删除光标所在行

dw 删除当前字符到单词尾包括空格的所有字符

 

撤销操作

u 撤销最近一次操作

 

复制操作

yy 复制当前行

[n]yy 复制n行

y^复制光标到行首

y$复制光标到行莫

 

 

显示行号

set nu

set nonu 取消行号

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值