vi

Linux下 vim的使用

情到浓时终转凉″ 提交于 2020-01-15 02:34:50
0.vi与vim vi编辑器是所有Unix及Linux系统下的标注编辑器,它就相当于Windows系统中的记事本一样,它的强大不逊色于任何最新的文本编辑器。它是我们使用Linux系统不能缺少的工具。由于对Unix及Linux系统的任何版本,vi编辑器是完全相同的,学会它后,可以在Linux的世界里畅行无阻。 vim具有程序编辑的能力,可以以字体颜色辨别语法的正确性,方便程序设计。 vim可以看作是vi的升级版本,它可以用多种颜色的方式来显示一些特殊的信息。 vim会根据文件扩展名或者是文件内的开头信息,判断该文件的内容而自动的执行该程序的语法判断式,再以颜色来显示程序代码与一般信息。 vim里面加入了许多额外的功能,例如支持正则表达式的搜索、多文件编辑、块复制等等。这对我们在Linux上进行一些配置文件的修改工作是很棒的功能。 1.为什么要学vi 所有的Unix like系统都会内建vi文本编辑器,其他的文本编辑器则不一定会存在。 一些软件的编辑接口会主动调用vi(例如corntab、visudo、edquota等命令) 2.vi的使用 vi拥有三种模式: 一般模式、编辑模式和命令行模式。 一般模式: 以vi打开一个文件就直接进入一般模式了(这是默认的模式)。在这个模式中,你可以使用键盘上的上下左右按键来移动光标,也可以使用删除字符或删除整行来处理文件内容,也可以使用复制

005 vim程序编辑器

情到浓时终转凉″ 提交于 2020-01-15 02:30:35
1. 为何要学 vim 所有的 Unix Like 系统都会内建 vi 文本编辑器,其他的文书编辑器则不一定会存在; 很多个别软件的编辑接口都会主动呼叫 vi (例如未来会谈到的 crontab , visudo , edquota 等指令); vim 具有程序编辑的能力,可以主动的以字体颜色辨别语法的正确性,方便程序设计; 因为程序简单,编辑速度相当快速。 2. vi 的使用 vi共有三种模式:一般模式、编辑模式、指令列命令模式 一般模式 : 以 vi 打开一个文件就直接进入一般模式了(这是默认的模式)。可以使用“上下左右”移动光标,可以使用“删除字符”或“删除整行”处理文件内容,也可以使用复制和粘贴进行处理。 编辑模式 : 在一般模式中可以进行删除、复制、粘贴等等的操作,但是却无法编辑文件内容的, 要等到你按下『i, I, o, O, a, A, r, R』等任何一个字母之后才会进入编辑模式。而如果要回到一般模式时, 则必须要按下『Esc』这个按键即可退出编辑模式。 命令行模式 : 在一般模式当中,输入『 : / ? 』三个中的任何一个按钮,就可以将光标移动到最底下那一行。在这个模式当中, 可以进行查找操作,而读取、保存、大量取代字符、离开 vi 、显示行号等等的操作也是在此模式中完成的 一般模式可与编辑模式及命令行模式切换, 但编辑模式与命令行 模式之间不可互相切换 ①

Linux vi/vim编辑器常用命令与用法总结

独自空忆成欢 提交于 2020-01-15 00:56:06
(一)vi/vim是什么? Linux世界几乎所有的配置文件都是以纯文本形式存在的,而在所有的Linux发行版系统上都有vi编辑器,因此利用简单的文字编辑软件就能够轻松地修改系统的各种配置了,非常方便。vi就是一种功能强大的文本编辑器,而vim则是高级版的vi,不但可以用不同颜色显示文字内容,还能进行诸如shell脚本、C语言程序编辑等功能,可以作为程序编辑器。 (二)为什么要学习vi/vim? 首先所有的Linux发行版系统上都会默认内置vi编辑器,而不一定带有其他文本编辑器,非常通用;其次,很多软件的编辑接口都会默认调用vi;第三,vi具有程序编辑的能力;最后,vi程序简单,编辑速度相当快速。 (三)vi的三种模式及各个模式之间的转换关系 (四)一般模式常用操作 【h(或向左方向键)】 光标左移一个字符 【j(或向下方向键)】 光标下移一个字符 【k(或向上方向键)】 光标上移一个字符 【l(或向右方向键)】 光标右移一个字符 【[Ctrl] + f】 屏幕向下移动一页(相当于Page Down键) 【[Ctrl] + b】 屏幕向上移动一页(相当于Page Up键) 【[0]或[Home]】 光标移动到当前行的最前面 【[$]或[End]】 光标移动到当前行的末尾 【G】 光标移动到文件的最后一行(第一个字符处) 【nG】 n为数字(下同),移动到当前文件中第n行 【gg】

VitualBox centos7 最小化安装

丶灬走出姿态 提交于 2020-01-14 23:30:30
1: 安装虚拟机 过程就不说了 , 主要是网络设置, 如下 : 2 设置网络 : 如果是按照上图设置的 , 那么开机后网络就能自动连接上了 。 如果ip需要改,如下 : 使用静态 IP 地址配置网络 # ip addr show # vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 增加下面内容 BOOTPROTO=none ONBOOT=yes IPADDR=192.168.100.123 GATEWAY=192.168.100.253 DNS1=192.168.100.253 DNS2=202.96.128.68 3. 关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running) 4. 关闭 SELinux vi /etc/selinux/config #注释掉下面两行 #SELINUX=enforcing #SELINUXTYPE=targeted #增加一行 SELINUX=disabled setenforce 0 shutdown -r now 5

how to edit the _wimrc to open html file with firefox in vim?

自闭症网瘾萝莉.ら 提交于 2020-01-14 14:51:49
问题 I am learning html, want to edit a html file in vim , when i finished the html file, press F4 to run it with firefox or chrome, how can i write a line in my _vimrc configuration file to do so ? in my _vimrc : :map <F4> :w !c:\Program Files\Mozilla Firefox\firefox.exe<cr> :map <F5> :w !firefox<cr> i have set my environment path c:\Program Files\Mozilla Firefox\firefox.exe neither of them can run ,i got can't find command . when i revise the configuration line into : :map <F4> :w !"c:\Program

Using the Python shell in Vi mode on Windows

前提是你 提交于 2020-01-14 13:14:37
问题 I know that you can use the Python shell in Vi mode on Unix-like operating systems. For example, I have this line in my ~/.inputrc : set editing-mode vi This lets me use Vi-style editing inside the Python shell. But can this be made to work when using Python on a Windows XP box? I'm using the pre-built Python for Windows downloaded directly from python.org. I'm guessing that the Windows version does not use the GNU Readline library, but I'd be happy to be proven wrong. :) 回答1: Install

How to type ^A in unix shell script/VI

守給你的承諾、 提交于 2020-01-14 12:54:07
问题 I am new to unix and writing script to extract data in delimited file format. want to use ^A as delimiter , can you please suggest how to type/insert it 回答1: Type Ctrl + V , then Ctrl + A . According to your system configuration, you may need to type other key sequence. Check the output of stty -a , especially lnext : $ stty -a | grep lnext lnext = ^V; flush = ^O; min = 1; time = 0; ^^^^^^^^^^ 回答2: In vi , you can generally type CTRL-V in insert mode, followed by another control character.

Advanced searching in Vim

笑着哭i 提交于 2020-01-12 07:37:06
问题 Is there a way to search for multiple strings simultaneously in Vim? I recall reading somewhere that it was possible but somehow forgot the technique. So for example, I have a text file and I want to search for "foo" and "bar" simultaneously (not necessarily as a single string, can be in different lines altogether). How do I achieve that? 回答1: /^joe.*fred.*bill/ : find joe AND fred AND Bill (Joe at start of line) /fred\|joe : Search for FRED OR JOE 回答2: Actually I found the answer soon after

autoindent is subset of smartindent in vim?

柔情痞子 提交于 2020-01-11 18:49:32
问题 :help autoindent : Copy indent from current line when starting a new line (typing in Insert mode or when using the "o" or "O" command). ... :help smartindent : Do smart autoindenting when starting a new line. Works for C-like programs, but can also be used for other languages. ... Normally 'autoindent' should also be on when using 'smartindent'. An indent is automatically inserted: After a line ending in '{'. After a line starting with a keyword from 'cinwords'. Before a line starting with '}

vim “modifiable” is off

℡╲_俬逩灬. 提交于 2020-01-11 14:51:15
问题 Trying to create a new file with nerd tree. I hit the a key to create a new file and i get the message: E21: Cannot make changes, 'Modifiable' is off I'm using MacVim and Janus (almost out of the box) 回答1: :set ma which is short for :set modifiable will make a buffer modifiable. And :set noma does the opposite. 回答2: I am not familiar with NerdTree but I guess that by typing a into a nerdtree view, it is interpreted as " I want to append something in the nerdtree buffer", and that buffer is