# ------------------- VI basic -------------------------------

# file name: VI_basic
# author   :
# date     : 2014-3-25
# contact  : QQ :
#            email :
# summary  : VI editor operation for programming

# ------------------- VI basic -------------------------------

# ------ summary ---------------------------------------------
vi is an powerful file editor for programming in Linux OS.
vim       : vi improved
gvim      : GUI of vi
two mode  : editing and command mode
.vim      : highligh word file
.vimrc    : configuration file of VI

# ------ file operation -----------------------------------------

# ------ open a file -----------
vi file_name   : open a file for editing on a terminal
vim file_name  :
gvim file_name : gvim is a GUI of vi

# when open a file , vi is in insert mode by default

:i     : go to insert mode
esc   : go to command mode
:w     : write into the file (save)
:q     : quit vi
:q!    : force to quit and abort the modification
:wq    : save and quit

# ----- move cursor ------------
->/<-     : left/right/up/down
h|j|k|l   : h(left)| j(down) | k(up) l (right)
          : 3h | 4j | 5k | 6l
:w        : move forward one word eg. 3w
:b        : move backward one word eg. 4b
:$        : move to the end of a line
:^|0      : move to the beginning of a line
# ---------------------------

:gg          : go to the first line
:G           : go to the last line
:nG          : go to n line eg. 1G
:set nu      : set number line
:set nonu
CTRL + G    : display the current line and total numbers of lines
CTRL + U    : page up
CTRL + D    : page down

# ----- delete copy and paste -----

d=delete, y=copy, p=paste

:dd       : delete a line eg. 5dd
:dw       : delete a word eg. d3w
:d0       :
:d$       : delete to end of line

:yy       : copy a line et. 5yy
:yw
:y0
:y$
:Y        : copy
:5,10y    : copy 5 ~ 10 line
:,10y     : copy cursor ~ 10 line
:5,y      : copy 5 ~ cursor line

:p        : paste

:.        : repeat last operation 

:x        : delete a character eg. 3x

# ------ undo the editing  ----
:u|U      : undo
:CTRL+R   : need the modification

# ------ insert cursor -------------------
a|A       : after the cursor | end of a line
o|O       : input one new line under the current line | up the current line
:help a   : 

# ------ search  ---------------------
:/pattern : go to the pattern
          : n|N
:?pattern :
SHIFT + * : match the word marked cursor
:number_line : go to the number line

# ----- replace -----------------------
:r|R          : replace
:%s/x/y/g     : x change to y all of them
:s/x/y/g      : x change to y on the current line
:10,23s/x/y/g : 

# ----- special operation ------------------
:sp       : splite horizontally ; put some files into one terminal
CRTL + WW : change file in splite command
:ZZ|q     : quit a splite file

:set diff : compare two files
:vsp      : visual splite vertically
CRTL + WW : 

CRTL + V  : visual mode
          : d|D , y|Y, r | R 

gf        : go into file
CRTL + O  : return the original file 

# ------ other command -------------------
:.    		: repeat last operation
:J        : Merge the under line and the current line eg. 3JA
:r        : replace
:~        : change case-sensitive character 

# ----- auto complenment ----------------

  

常用VI操作命令的更多相关文章

  1. 【Linux学习】Vi 操作命令集合

    Vi 操作命令集合 进入vi的命令 vi filename :打开或新建文件,并将光标置于第一行首 vi +n filename :打开文件,并将光标置于第n行首 vi + filename :打开文 ...

  2. CentOS运维常用管理操作命令

    自己整理的整理Linux常用运维和linux常用管理操作命令,当然不是非常详细和丰富,但是也基本上够用了吧.欢迎留言补充更多的Linux常用运维和linux常用管理操作命令.不断完善中.... 备份m ...

  3. git中常用的操作命令有哪些?常用操作命令归纳

    git中常用的操作命令有哪些?本篇文章就给到大家归纳了一些git中常用操作命令.有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. git开始 全局配置:配置用户名和e-mail地址 1 ...

  4. 记录 git 常用的操作命令总结

    记录 git 常用的操作命令总结 2016-12-15 16:44:04 作为一名开发者,熟悉使用 git 代码管理工具是一项必备的基本技能.git 相较 SVN 而言,其优点不言而喻.git 的功能 ...

  5. dos常用文件操作命令

    1.DIR 含义: 显示指定目录下的文件和子目录列表 类型: 内部命令 格式: DIR[drive:][path][filename][/p][/w][/A[[:]attributes]][/O[[: ...

  6. centos文件/文件夹操作-检查磁盘、内存、cpu使用情况-vi操作命令

    Part1:CentOS文件/文件夹操作 1.新建文件夹 即创建目录 mkdir 文件名 新建一个名为test的文件夹在home下 vi source1 mkdir /home/test 注意:当创建 ...

  7. GlusterFS常用维护操作命令

    GlusterFS常用维护操作命令 1.启动/关闭/查看glusterd服务 # /etc/init.d/glusterd start # /etc/init.d/glusterd stop # /e ...

  8. [Linux] Linux常用文本操作命令整理

    简单的总结一下常用的一些实用的Linux文本操作命令,包括wc(统计).cut(切分).sort(排序).uniq(去重).grep(查找).sed(替换.插入.删除).awk(文本分析). 1.统计 ...

  9. Linux vi 操作命令整理

    转自:http://www.lupaworld.com/?uid-296380-action-viewspace-itemid-118973   vi/vim 基本使用方法 本文介绍了vi (vim) ...

随机推荐

  1. 基于TI CC2650的IPv6 over BLE(BLEach) demo

    虽然BLE 5.0协议理论上已经开始支持IPv6了,但是目前市面上还没有可用的实现IPv6通信的BLE产品. 最近在网上看到一个开源的基于contiki系统,在CC2650上实现的IPv6 over ...

  2. CUDA共享内存的使用示例

    CUDA共享内存使用示例如下:参考教材<GPU高性能编程CUDA实战>.P54-P65 教材下载地址:http://download.csdn.net/download/yizhaoyan ...

  3. Java 获得Class的绝对路径方法

    Java获得class文件的绝对路径:1.e.g. Foo.class => Foo.class.getResuorce("").getFile(); 该方法在eclipse ...

  4. JavaScript的三种类型检测typeof , instanceof , toString比较

    1.typeof typeof是js的一个操作符,在类型检测中,几乎没有任何用处. typeof 返回一个表达式的数据类型的字符串,返回结果为javascript中的基本数据类型,包括:number. ...

  5. Java 调用python说明文档

    Java 调用python说明文档 通过java调用python脚本主要如下三种方式: 1.直接执行python脚本: 2.执行python.py文件: 3.使用Runtime.getRuntime( ...

  6. linux_inotify

    什么是inotify? 拥有强大.粒细粒度.异步文件系统事件监控机制,监控文件系统中添加.删除.修改.移动等各种事件 版本支持: 内核 2.6.13以上版本,inotify-tools 是实施监控的软 ...

  7. java —— equals 与 ==

    equals 众所周知,java 中的所有的类都继承自 Object 这个超类 ,他就是Java所有类的父类或祖先类,Object类里面有一个equals方法,并且提供了默认的实现,如下所示. pub ...

  8. 在Tomcat中配置连接池和数据源

    1.DataSource接口介绍 (1)DataSource 概述 JDBC1.0原来是用DriverManager类来产生一个对数据源的连接.JDBC2.0用一种替代的方法,使用DataSource ...

  9. Asp.net core 2.0.1 Razor 的使用学习笔记(一)

    环境:vs2017 版本:15.5.6 一.新建项目 1.文件>新建>项目>Visual c#>.NET Core>ASP.NET Core Web应用程序(“.NET ...

  10. Mac 管理员变为了普通用户怎么办?

    开机的时候一直按住 command+s 出现命令行终端的时候按照以下顺序输入命令: /sbin/mount -uw    回车rm var/db/.AppleSetupDone   回车 reboot ...