vi

linux中vi保存文件时的“Can't open file for writing”

寵の児 提交于 2019-12-26 20:31:52
今天在ubuntu 13.04环境下,使用vi新建一个文件,编辑保存时提示“Can't open file for writing”。 分析: 出现这个错误的原因可能有两个: 一是当前用户的权限不足; 二是此文件可能正被其他程序或用户使用。 第一项的解决方案是在使用vi命令打开文件时,前面加上sudo来临时提供管理员权限,即使用命令“sudo vi 文件名”打开编辑文件。 由此看来,sudo命令是很有用的,当我们执行某种操作系统提示诸如“operation not permitted”等权限不足信息时,我们很多时候都可以在命令前面加上sudo来解决权限不足问题。 来源: https://www.cnblogs.com/kongzhongqijing/p/3531506.html

vi编辑器的一些基本操作

六眼飞鱼酱① 提交于 2019-12-26 16:34:34
1.vi编辑器的启动、退出: (1)启动:vi filename (2)退出: ZZ 、 :wq 、 :q! 或 :x 2.vi编辑器的三种工作方式: (1)vi三种工作方式及操作: (2)vi三种工作方式及相互切换: 3.使用vi编辑器编辑文本: (1)光标移动: 左右上下移可以用上下左右方向键或hjkl 行间移动: (2)文本插入 说明:在命令方式下输入这些字符后即进入输入方式,等待用户输入;按ESC键返回命令方式 (3)文本删除、复制、粘贴 (4)撤销、重做 u 撤销上一次操作 . 重做上一次操作 (5)文本查找、替换 (6)文本保存和退出 原文链接: https://wenku.baidu.com/view/ef4d913ee87101f69e319544?fromShare=1#17 来源: CSDN 作者: 梦里逆天 链接: https://blog.csdn.net/username666/article/details/103713827

vim的使用

做~自己de王妃 提交于 2019-12-26 12:34:03
https://www.cnblogs.com/litterrondo/archive/2013/05/18/3085654.html 1.Vim的三种模式 vi/vim有三种执行模式:命令模式、插入模式和编辑模式。 使用vi/vim打开文件时默认进入命令模式,三种模式之间的切换如上图所示。 2. 插入命令 在命令模式下键入插入命令会进入到插入模式下,插入模式下可以输入文本。 i: 在光标前插入, I: 在光标所在行的行首插入 a:在光标后插入, A:在光标所在行行尾插入 o:在光标所在行上插入新行,O:在光标所在行下插入新行 3. 光标移动命令 在命令模式下键入,改变光标位置 h:光标左移, j:光标下移, k:光标上移, l:光标右移动 H:光标定位到屏幕最上面一行, M:光标移动到屏幕中央, L:光标移动到屏幕最下方 0: 光标移动到行首, $光标移动到行尾 4. 定位命令 在命令模式下键入,定位光标位置 gg:回到文件首行, G:回到文件尾行 :n和nG: 光标定位到文件第n行(:20或20G表示光标定位到第20行) :set nu 或:set number显示行号, :set nonu 取消显示行号 5. 删除命令 在命令模式下键入,删除文件中的内容 x : 删除光标所在字符, nx:删除光标后n个字符 dd:删除光标所在行,ndd:删除光标所在行以后的n行 D

Editing _vimrc in Windows

自古美人都是妖i 提交于 2019-12-25 14:11:38
问题 I am having some trouble with VIM on windows, and I was wondering if anyone could be of assistance. As of right now, I am trying to make it so that when VIM starts, it changes it's working directory to one besides the default (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Vim 7.3) . The way I am going about this is adding in cd $HOME\Desktop\VimFiles , where $HOME is C:\Users\Alphabet (Alphabet is the name of my account). The issue I am running into right now is that after opening up

Editing _vimrc in Windows

懵懂的女人 提交于 2019-12-25 14:11:35
问题 I am having some trouble with VIM on windows, and I was wondering if anyone could be of assistance. As of right now, I am trying to make it so that when VIM starts, it changes it's working directory to one besides the default (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Vim 7.3) . The way I am going about this is adding in cd $HOME\Desktop\VimFiles , where $HOME is C:\Users\Alphabet (Alphabet is the name of my account). The issue I am running into right now is that after opening up

Opening editor while the edit mode is vi in Readline

假装没事ソ 提交于 2019-12-25 11:17:10
问题 I have set my readline mode to be vi in my ~/.inputrc set editing-mode vi I came to know that when you are in command mode, you can press v to open up current line in the editor defined in $EDITOR variable. This works for me. But when I change the content in my editor, I am not sure how to get those changes back to my command line. How to do that? 回答1: After you make your changes just save and quit. The command will be executed after you quit. If you want to look at the command after you have

VIM how to replace “AA” to “BB” in a file

喜欢而已 提交于 2019-12-25 02:39:11
问题 I need to replace a file which has thousand of lines code. In the log, it has a specific word which I want to replace this work with some other words. Say, how to replace all "AA" to "BB" in this file? thanks 回答1: You want to use :%s/\<AA\>/BB/g % specifies that you want to replace on all lines. s tells vim that you want to do a substitution Between the first / and second / is what you want to replace (ie \<AA\> ). The \< and the \> are word boundaries , making sure that AA is matched but fAA

VIM how to replace “AA” to “BB” in a file

喜夏-厌秋 提交于 2019-12-25 02:39:10
问题 I need to replace a file which has thousand of lines code. In the log, it has a specific word which I want to replace this work with some other words. Say, how to replace all "AA" to "BB" in this file? thanks 回答1: You want to use :%s/\<AA\>/BB/g % specifies that you want to replace on all lines. s tells vim that you want to do a substitution Between the first / and second / is what you want to replace (ie \<AA\> ). The \< and the \> are word boundaries , making sure that AA is matched but fAA

vi编辑器常见命令的使用

五迷三道 提交于 2019-12-25 02:16:25
Linux下的文本编辑器有很多种,vi 是最常用的,也是各版本Linux的标配。注意,vi 仅仅是一个文本编辑器,可以给字符着色,可以自动补全,但是不像 Windows 下的 word 有排版功能。 vi 是十年磨一剑的产品,虽然命令繁多,并且大多数功能都是依靠键盘输入来完成,但是一旦你熟悉后,会发现 vi 的功能和效率是其他图形界面编辑器无法比拟的。 Vim 是 V i im proved 的缩写,是 vi 的改进版。在Linux中,vi 被认为是事实上的标准编辑器,因为: 所有版本的 Linux 都带有 vi 编辑器; 占用资源少; 与 ed、ex 等其他编辑器相比,vi 对用户更加友好。 你可以使用 vi 编辑器编辑现有的文件,也可以创建一个新文件,还能以只读模式打开文本文件。 进入 vi 编辑器 可以通过以下方式进入 vi 编辑器: 命令 描述 vi filename 如果filename存在,则打开;否则会创建一个新文件再打开。 vi -R filename 以只读模式(只能查看不能编辑)打开现有文件。 view filename 以只读模式打开现有文件。 例如,使用 vi 编辑器创建一个新文件并打开: $vi testfile | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "testfile" [New File] 竖线(|)代表光标的位置;波浪号(~

Linux vi 编辑器常见命令的使用

自作多情 提交于 2019-12-25 02:15:12
Linux vi 编辑器常见命令的使用 Linux下的文本编辑器有很多种,vi 是最常用的,也是各版本Linux的标配。注意,vi 仅仅是一个文本编辑器,可以给字符着色,可以自动补全,但是不像 Windows 下的 word 有排版功能。 vi 是十年磨一剑的产品,虽然命令繁多,并且大多数功能都是依靠键盘输入来完成,但是一旦你熟悉后,会发现 vi 的功能和效率是其他图形界面编辑器无法比拟的。 Vim 是 Vi improved 的缩写,是 vi 的改进版。在Linux中,vi 被认为是事实上的标准编辑器,因为: 所有版本的 Linux 都带有 vi 编辑器; 占用资源少; 与 ed、ex 等其他编辑器相比,vi 对用户更加友好。 你可以使用 vi 编辑器编辑现有的文件,也可以创建一个新文件,还能以只读模式打开文本文件。 进入 vi 编辑器 可以通过以下方式进入 vi 编辑器: 命令 描述 vi filename 如果filename存在,则打开;否则会创建一个新文件再打开。 vi -R filename 以只读模式(只能查看不能编辑)打开现有文件。 view filename 以只读模式打开现有文件。 例如,使用 vi 编辑器创建一个新文件并打开: $vi testfile | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "testfile" [New File] 竖线(|