免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 17870 | 回复: 9
打印 上一主题 下一主题

命令行的CentOS 5.2里,如何退出VI编辑器? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-25 06:05 |只看该作者 |倒序浏览
命令行的CentOS 5.2里,如何退出VI编辑器?

进入是输入vi吗?

退出是输入q吗?

我的电脑,怎么没反应的?不能退出。只好直接关闭电源了。


论坛徽章:
0
2 [报告]
发表于 2009-05-25 07:02 |只看该作者


按ESC
在输入:
在输入q!

在reboot

论坛徽章:
0
3 [报告]
发表于 2009-05-25 07:50 |只看该作者
楼上正解,先退出VI的编辑状态,按ESC键。然后输入:q!,表示不保存退出

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
4 [报告]
发表于 2009-05-25 08:23 |只看该作者
esc
:q

论坛徽章:
0
5 [报告]
发表于 2009-05-25 11:09 |只看该作者
VI Editor Commands

Vi has two modes insertion mode and command mode.
The editor begins in command mode, where cursor movement and copy/paste editing occur.
Most commands execute as soon as typed except for "colon" commands which execute when you press the return key.

Switch to Text or Insert mode:
                   
Open line above cursor
        O                                        
Insert text at beginning of line
        I        
Insert text at cursor
        i        
Insert text after cursor
        a        
Append text at line end
        A
                   
Open line below cursor
        o                                        

Switch to Command mode:
Switch to command mode
        <ESC>

Cursor Movement (command mode):
                   
Scroll Backward 1 screen
        <ctrl>b                    
                   
Scroll Up 1/2 screen
        <ctrl>u                    
Go to beginning of line
        0        
Go to line n
        nG        
Go to end of line
        $
                   
Scroll Down 1/2 screen
        <ctrl>d        
Go to line number ##
        :##
                   
Scroll Forward 1 screen
        <ctrl>f                    
                   
Go to last line
        G                    
Scroll by sentence f/b         ( )                                        
Scroll by word f/b         w b         Move left, down, up, right         h j k l        
Left 6 chars
        6h
Scroll by paragraph f/b         { }         Directional Movement         Arrow Keys        
Go to line #6
        6G

Deleting text (command mode):
Change word
        cw        
Replace one character
        r                    
Delete word
        dw        
Delete text at cursor
        x        
Delete entire line (to buffer)
        dd
                   
Delete (backspace) text at cursor
        X        
Delete 5 lines (to buffer)
        5dd
                    Delete current to end of line         D        
Delete lines 5-10
        :5,10d

Editing (command mode):
Copy line
        yy        
Copy n lines
        nyy        
Copy lines 1-2/paste after 3
        :1,2t 3
Paste above current line
        P        
                             
Paste below current line
        p                            
Move lines 4-5/paste after 6
        :4,5m 6
                                       
Join previous line
        J
Search backward for string
        ?string        
Search forward for string
        /string         Find next string occurrence         n
% (entire file) s (search and replace) /old text with new/ c (confirm) g (global - all)
        :%s/oldstring/newstring/cg                            
Ignore case during search
        :set ic
Repeat last command
        .        
Undo previous command
        u        
Undo all changes to line
        U

Save and Quit (command mode):
Save changes to buffer
        :w        
Save changes and quit vi
        :wq        
Save file to new file
        :w file
                   
Quit without saving
        :q!        
Save lines to new file
        :10,15w file

论坛徽章:
0
6 [报告]
发表于 2009-05-25 16:39 |只看该作者
原来要按两下。我以为一次性按两个键。

论坛徽章:
0
7 [报告]
发表于 2009-05-25 16:41 |只看该作者
按ESC
输入:
输入q

论坛徽章:
34
亥猪
日期:2015-03-20 13:55:11戌狗
日期:2015-03-20 13:57:01酉鸡
日期:2015-03-20 14:03:56未羊
日期:2015-03-20 14:18:30子鼠
日期:2015-03-20 14:20:14丑牛
日期:2015-03-20 14:20:31辰龙
日期:2015-03-20 14:35:34巳蛇
日期:2015-03-20 14:35:56操作系统版块每日发帖之星
日期:2015-11-06 06:20:00操作系统版块每日发帖之星
日期:2015-11-08 06:20:00操作系统版块每日发帖之星
日期:2015-11-19 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13
8 [报告]
发表于 2009-05-25 16:43 |只看该作者
命令模式下的 ZZ 也是保存退出,实在不行还可以换 tty 么~

论坛徽章:
0
9 [报告]
发表于 2009-05-25 16:48 |只看该作者
楼主头像好可爱。

论坛徽章:
0
10 [报告]
发表于 2009-05-25 17:13 |只看该作者
过掌。

这可是熊猫烧香呀。不过,好像Linux当时没有感染过。

不知道为什么。

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP