网上能够找到的,关于VI的教程,更是多为能吓死人的上百页说明。事实上, 从我个人的实践看,全然不须要如此夸张。要完毕最主要的编辑。仅仅要熟悉几个命令,就是把VIM用得非常好。

这里就列举一下:

Esc:这个是VIM中的万能功能键之中的一个。基本上不论什么时候按这个键,都能够返回VIM的普通状态。

i:在普通状态下,按i能够进入“插入”编辑状态。这个时候按方向键移动光标,在想要输入的地方输入字符。用Del键删除 字符,最后用Esc退出到普通状态。

yy(yny):在普通状态下。把光标用方向键移动到想要复制的某行文字上,按两下y。就是复制这一行。假设是想复制这行 一下n行,就用yny方式。如复制5行,就是y5y。

p:复制后,移动光标到要粘贴的地方,按p既可。

d:和上面相对,按d就是删除当前行。

x:在普通模式下,按x就是删除光标当前位置的字符,汉字就是整个汉字。

:wq!:在普通模式下输入“:”就进入命令状态,在这个状态下,q代表退出。w代表保存,!代表强制。比方放弃改动。就 是:q!。强制保存退出就是:wq!。

在「命令行模式(command mode)」下。按一下「:」冒号键进入「Last line mode」。比如:

: w filename (输入 「w filename」将文章以指定的文件名称filename保存)

: wq (输入「wq」。存盘并退出vi)

: q! (输入q!, 不存盘强制退出vi)

查找字符

 「/keyword」:先按「/」键。再输入您想寻找的字符,假设第一次找的keyword不是您想要的。能够一直按「n」会往后寻找到您要的keyword为止。

好啦,就这么简单。VIM是一个强大到BT的编辑软件。并且绝对很袖珍。可惜,要用好这个软件,绝对不是easy的事情。我 想我们这种人。全然不须要一上来就学习那么多根本用不上的技巧,先能用上最主要的功能在说。记住上面这七条,VIM全然就能够为我所用了。

设置属性

设置一些属性。

在终端输入 sudo -s进入根文件夹,

随后输入password,然后是cd etc/vim

接着是 vim vimrc

注意。cd时候加一个/,才干进入当前路径

随后是设置一些属性。

在终端输入 sudo -s进入根文件夹,

随后输入password,然后是cd etc/vim

接着是 vim vimrc

此时便会出现etc/vim/vimrc里面的内容。大致例如以下:

大致例如以下:



" All system-wide defaults are set in $VIMRUNTIME/debian.vim(usually just

" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to:runtime

" you can find below. If you wish to change any of those settings,you should

" do it in this file (/etc/vim/vimrc), since debian.vim will beoverwritten

" everytime an upgrade of the vim packages is performed. It isrecommended to

" make changes after sourcing debian.vim since it alters the valueof the

" 'compatible' option.



" This line should not be removed as it ensures that variousoptions are

" properly set to work with the Vim-related packages available inDebian.

runtime! debian.vim



" Uncomment the next line to make Vim more Vi-compatible

" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible'changes numerous

" options, so any other options should be set AFTER setting'compatible'.

"set compatible



" Vim5 and later versions support syntax highlighting. Uncommentingthe next

" line enables syntax highlighting by default.

"syntax on



" If using a dark background within the editing area and syntaxhighlighting

" turn on this option as well

"set background=dark



" Uncomment the following to have Vim jump to the last positionwhen

" reopening a file

"if has("autocmd")

" au BufReadPost * if line("'\"") > 0 && line("'\"")<= line("$")

"    \| exe"normal g'\"" | endif

"endif



" Uncomment the following to have Vim load indentation rulesaccording to the

" detected filetype. Per default Debian Vim only load filetypespecific

" plugins.

"if has("autocmd")

" filetype indent on

"endif



" The following are commented out as they cause vim to behave alot

" differently from regular Vi. They are highly recommendedthough.

"set showcmd       " Show(partial) command in status line.

"setshowmatch       " Showmatching brackets.

"setignorecase       " Do caseinsensitive matching

"setsmartcase       " Do smartcase matching

"setincsearch       "Incremental search

"setautowrite       "Automatically save before commands like :next and :make

"sethidden            " Hide buffers when they are abandoned

"set mouse=a       " Enablemouse usage (all modes) in terminals



" Source a global configuration file if available

" XXX Deprecated, please move your changes here in/etc/vim/vimrc

if filereadable("/etc/vim/vimrc.local")

source /etc/vim/vimrc.local

endif

然后按下i键(插入命令),此时在最以下会出现“--插入--”的字样,随后将下列语句插入到最后(能够依据凝视结合自己的须要来取舍。不一定要所有写入)

setai                      "自己主动缩进。新行与前面的行保持—致的自己主动空格

set aw                    "自己主动写。转入shell或使用:n编辑其它文件时。当前的缓冲区被写入

set flash                 "在出错处闪烁但不呜叫(缺省)

set ic                      "在查询及模式匹配时忽赂大写和小写

setnu        

set number             "屏幕左边显示行号

setshowmatch         " 显示括号配对,当键入“]”“)”时,高亮度显示匹配的括号

setshowmode          " 处于文本输入方式时加亮button条中的模式指示器

setshowcmd            "在状态栏显示眼下所运行的指令,未完毕的指令片段亦会显示出来

setwarn/nowarn       " 对文本进行了新的改动后,离开shell时系统给出显示(缺省)

setws/nows             " 在搜索时如到达文件尾则绕回文件头继续搜索

setwrap/nowrap       " 长行显示自己主动折行

colorscheme evening " 设定背景为夜间模式

filetype pluginon       " 自己主动识别文件类型,自己主动匹配相应的, “文件类型Plugin.vim”文件,使用缩进定义文件

setautoindent           " 设置自己主动缩进:即每行的缩进值与上一行相等。使用 noautoindent 取消设置

set cindent              " 以C/C++的模式缩进

setnoignorecase      " 默认区分大写和小写

setruler                    " 打开状态栏标尺

setscrolloff=5           " 设定光标离窗体上下边界 5 行时窗体自己主动滚动

setshiftwidth=4         " 设定 << 和 >> 命令移动时的宽度为 4

set softtabstop=4      "使得按退格键时能够一次删掉 4 个空格,不足 4 个时删掉全部剩下的空格)

settabstop=4          " 设定 tab 长度为 4

setwrap                   "自己主动换行显示

syntax enable

syntaxon                  " 自己主动语法高亮

然后按ESC退出编辑状态,以下的“--插入--”消失。

接着按:w保存文件

随后是:q退出vim返回终端

如此便完毕了对于vim的安装和设定。

最新文章

  1. Mac下没有权限启动tomcat的解决办法
  2. Visual Studio 2015 前端开发工作流
  3. RPM
  4. Init
  5. Evaluate Reverse Polish Notation(堆栈)
  6. 今天晚上 中国互联网被Struts2漏洞血洗
  7. Hibernate 配置派生属性
  8. PHP 的try catch 报错捕获机制
  9. BZOJ 2434 阿狸的打字机
  10. Highcharts 非常实用的Javascript统计图
  11. 算法----选择排序(select sort)
  12. BIP Requests Are Failing With Error &quot;OPP Error Oracle.apps.xdo.XDOException: Error Creating Lock Fil
  13. 用shell脚本挂载linux主机拷贝相应文件copy.sh
  14. Maven 学习总结 (二) 之 生命周期与插件
  15. 分析Linux内核5.0系统调用处理过程
  16. maven repository pom
  17. CancellationTokenSource 和 CancellationToken 取消线程
  18. YARN 启动后失败退出——没有请求资源——Invalid resource request, no resources request
  19. python3入门教程(一)之 hello world
  20. set 集合的知识

热门文章

  1. 关于CSS中float的两点心得以及清除浮动的总结
  2. websocket的原理
  3. [ ZJOI 2006 ] Mahjong
  4. [转]STL之list容器详解
  5. 史上巨坑: vim的&quot;set foldmethod=syntax&quot;设置竟然是导致ctrl+p(ctrl+n)补全在文件稍大时光标位于中间位置补全效率变慢的元凶!
  6. Java 基础入门随笔(1) JavaSE版——java语言三种技术架构
  7. 在Yosemite中创建个人站点
  8. VS2013支持多字节
  9. CSS3:变换和动画
  10. Python 之多线程应用