EDIT mode to GENERAL mode: press ESC

General mode: operate file

:q!    :force to close the file but not save(file has been modified)

:wq! :force to save and close the file

:q    : close the file but not save(file hasn't been modified)

:wq  : save and close the file

:w:save file

General mode to edit mode

i :insert a charactor before cursor, and enter EDIT mode

a : insert a charactor after cursor, and enter EDIT mode

o : insert a new line backward, and enter EDIT mode

General mode: move cursor

) :cursor move to the end of line

( :cursor move to the beginning of line

G : cursor move to the last line of the file

gg : cursor move to the first line of the file

General mode: delete

dd :delete(cut) the line where cursor is

D : delete the charactors in the back of cursor in a line, include the character of cursor

x,X:in the character of a line, x means "delete the character of cursor", X means "delete the character before cursor

General mode: OTHERS

u :cancel the last operation

:/linux : search linux, then tap 'n' to search the next one

:?linux: search linux, then tap 'n' to search the next one

p : paste the stuff after the line of cursor

P : paste the stuff before the line of cursor

set nu:show row number

General mode: execute cmd without exit vi/vim

:!cmd
不退出vim 执行命令 cmd

:r !cmd
不退出vim执行命令cmd,并将cmd的输出内容插入当前文本中。

:shell
切换到shell里(此时并没有退出vim,可以理解成vim转入后台),你可以在shell中做任何操作,退出shell(比如用exit)后,会切换回原来的vim中

vim 的一些设置

linux环境下vim的初始化配置文件为.vimrc, 通常有两个,分别是系统版本和用户版本,前者不同发行版linux会有不同,一般位于/etc/vimrc,是整个系统vim的默认配置;后者位于~/.vimrc,是当前用户的vim配置,会覆盖系统配置。

vim ~/.vimrc

set tabstop=     " 设置当前用户 vim 使用中 tab 是四个空格"

set fencs=utf-,GB18030,ucs-bom,default,latin1   " 显示中文字符"

set nocompatible  "关闭vi兼容模式,可以启用方向键和Backspace"

syntax on         "自动语法高亮(对于编程语言中的关键字高亮需要下载相应的编程语言对应的"配色方案.vim文件""

colorscheme industry "选择industry.vim配色方案,文件在/usr/share/vim/vimxx/colors,推荐 industry、slate、murphy"

不需要执行 source ~/.vimrc 即可生效(执行了反而提示某些指令找不到,比如 syntax)

Linux command ------ vi / vim的更多相关文章

  1. Linux系统Vi/Vim编辑器的简单介绍、安装/卸载、常用命令

    Linux系统Vi/Vim编辑器的简单介绍.安装/卸载.常用命令 1.介绍 vi(Visual Interface)编辑器是Linux和Unix上最基本的文本编辑器,工作在字符模式下.由于不需要图形界 ...

  2. 【转】Linux上vi(vim)编辑器使用教程

    Linux上vi(vim)编辑器使用教程 ------------------------------------------------------------ ikong ------------ ...

  3. Linux系统 vi/vim文本编辑器

    Linux系统 vi/vim文本编辑器 (一)Vim/Vi简介 (二)Vim/Vi工作模式 (三)Vim/Vi基本使用 (四)Vim/Vi应用技巧 (一)Vim/Vi简介 Vim/Vi是一个功能强大的 ...

  4. [Linux/Ubuntu] vi/vim 使用方法讲解(转载)

    转自:http://www.cnblogs.com/emanlee/archive/2011/11/10/2243930.html vi/vim 基本使用方法 vi编辑器是所有Unix及Linux系统 ...

  5. Linux命令vi/vim 使用方法讲解

    vi/vim 基本使用方法 vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令.由于对Unix及Linux系统的 ...

  6. [Linux/Ubuntu] vi/vim 使用方法讲解

    vi/vim 基本使用方法 vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令.由于对Unix及Linux系统的 ...

  7. 新手指南:Linux上vi(vim)编辑器使用教程

    vi(vim)是上Linux非常常用的编辑器,很多Linux发行版都默认安装了vi(vim).vi(vim)命令繁多但是如果使用灵活之后将会大大提高效率.vi是“visual interface”的缩 ...

  8. Linux下Vi/Vim的使用方法

    本文介绍了vi (vim)的基本使用方法,但对于普通用户来说基本上够了!i/vim的区别简单点来说,它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅兼容vi的所有指令,而且还有一些新的特 ...

  9. 【Linux】- vi/vim

    所有的 Unix Like 系统都会内建 vi 文书编辑器,其他的文书编辑器则不一定会存在. 但是目前我们使用比较多的是 vim 编辑器. vim 具有程序编辑的能力,可以主动的以字体颜色辨别语法的正 ...

随机推荐

  1. 20135316Linux内核学习笔记第八周

    20135316王剑桥<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC 1000029000 一.进程调度与进程调度的时机分析 ...

  2. 网络:Session原理及存储

    一.Session的工作流程 二.会话保持 会话保持是负载均衡最常见的问题之一,会话保持是指在负载均衡器上实现的一种机制,可以识别客户端与服务器之间交互过程的关连性,在作负载均衡的同时还保证一系列相关 ...

  3. SQL 别名

    Sql中添加别名有三种方式:

  4. Quartz中时间表达式的设置-----corn表达式 (转)(http://www.cnblogs.com/GarfieldTom/p/3746290.html)

    Quartz中时间表达式的设置-----corn表达式 (注:这是让我看比较明白的一个博文,但是抱歉,没有找到原作者,如有侵犯,请告知) 时间格式: <!-- s m h d m w(?) y( ...

  5. HttpServletResponse类学习

    /*//2) 乱码的解决. //设置服务器输出的编码为UTF-8---在BaseServlet处已经已经进行了设置 response.setCharacterEncoding("UTF-8& ...

  6. net license tool, EasyLicense !

    net license tool, EasyLicense ! 开源 .net license tool, EasyLicense !   介绍: 过去我常常像是否有一个帮助授权的软件,它可以非常简单 ...

  7. PAT L3-003 社交集群

    https://pintia.cn/problem-sets/994805046380707840/problems/994805053141925888 当你在社交网络平台注册时,一般总是被要求填写 ...

  8. loadrunner基础学习笔记五-场景

    场景目标:模拟10家旅行社同时登录.搜索航班.购买机票.查看航班路线并退出 负载测试是指在典型工作条件下测试应用程序,例如:多家旅行社同时在同一个机票预订系统中预订机票 controller提供所有用 ...

  9. python系列-1 字符串操作

    1.去除空格   str.strip():删除字符串两边的指定字符,括号的写入指定字符,默认为空格 >>> a=' hello ' >>> b=a.strip() ...

  10. BZOJ1803Spoj1487 Query on a tree III——主席树

    题目大意 给一棵有点权的n个点的有根树,保证任意两点的点权不同,m次询问每次询问x的子树中权值第k大的点. 输入 先输入n,然后每个点点权,再输入n-1行每行两个数x,y代表x和y相连,再输入m,之后 ...