最近VIM用的也越来越多了...因为确实在慢慢的把win下的编辑习惯转成unix下的编辑习惯..._vimrc也在不断的完善中先贴一下平时在VIM中使用中的命令...有很多也是我没有掌握的

(估计也是转的)原帖地址:http://www.oschina.net/news/43167/130-essential-vim-commands

基础

:e filename Open filename for edition
:w Save file
:q Exit Vim
:q! Quit without saving
:x Write file (if changes has been made) and exit
:sav filename Saves file as filename
. Repeats the last change made in normal mode
5. Repeats 5 times the last change made in normal mode

在文件中移动

k or Up Arrow move the cursor up one line
j or Down Arrow move the cursor down one line
e move the cursor to the end of the word
b move the cursor to the begining of the word
0 move the cursor to the begining of the line
G move the cursor to the end of the line
gg move the cursor to the begining of the file
L move the cursor to the end of the file
:59 move cursor to line 59. Replace 59 by the desired line number.
20| move cursor to column 20.
% Move cursor to matching parenthesis
[[ Jump to function start
[{ Jump to block start

剪切、复制和粘贴

y Copy the selected text to clipboard
p Paste clipboard contents
dd Cut current line
yy Copy current line
y$ Copy to end of line
D Cut to end of line

搜索

/word Search word from top to bottom
?word Search word from bottom to top
* Search the word under cursor
/\cstring Search STRING or string, case insensitive
/jo[ha]n Search john or joan
/\< the Search the, theatre or then
/the\> Search the or breathe
/\< the\> Search the
/\< ¦.\> Search all words of 4 letters
/\/ Search fred but not alfred or frederick
/fred\|joe Search fred or joe
/\<\d\d\d\d\> Search exactly 4 digits
/^\n\{3} Find 3 empty lines
:bufdo /searchstr/ Search in all open files
bufdo %s/something/somethingelse/g Search something in all the open buffers and replace it withsomethingelse

替换

:%s/old/new/g Replace all occurences of old by new in file
:%s/onward/forward/gi Replace onward by forward, case unsensitive
:%s/old/new/gc Replace all occurences with confirmation
:2,35s/old/new/g Replace all occurences between lines 2 and 35
:5,$s/old/new/g Replace all occurences from line 5 to EOF
:%s/^/hello/g Replace the begining of each line by hello
:%s/$/Harry/g Replace the end of each line by Harry
:%s/onward/forward/gi Replace onward by forward, case unsensitive
:%s/ *$//g Delete all white spaces
:g/string/d Delete all lines containing string
:v/string/d Delete all lines containing which didn’t contain string
:s/Bill/Steve/ Replace the first occurence of Bill by Steve in current line
:s/Bill/Steve/g Replace Bill by Steve in current line
:%s/Bill/Steve/g Replace Bill by Steve in all the file
:%s/^M//g Delete DOS carriage returns (^M)
:%s/\r/\r/g Transform DOS carriage returns in returns
:%s#<[^>]\+>##g Delete HTML tags but keeps text
:%s/^\(.*\)\n\1$/\1/ Delete lines which appears twice
Ctrl+a Increment number under the cursor
Ctrl+x Decrement number under cursor
ggVGg? Change text to Rot13

大小写

Vu Lowercase line
VU Uppercase line
g~~ Invert case
vEU Switch word to uppercase
vE~ Modify word case
ggguG Set all text to lowercase
gggUG Set all text to uppercase
:set ignorecase Ignore case in searches
:set smartcase Ignore case in searches excepted if an uppercase letter is used
:%s/\<./\u&/g Sets first letter of each word to uppercase
:%s/\<./\l&/g Sets first letter of each word to lowercase
:%s/.*/\u& Sets first letter of each line to uppercase
:%s/.*/\l& Sets first letter of each line to lowercase

读写文件

:1,10 w outfile Saves lines 1 to 10 in outfile
:1,10 w >> outfile Appends lines 1 to 10 to outfile
:r infile Insert the content of infile
:23r infile Insert the content of infile under line 23

文件浏览器

:e . Open integrated file explorer
:Sex Split window and open integrated file explorer
:Sex! Same as :Sex but split window vertically
:browse e Graphical file explorer
:ls List buffers
:cd .. Move to parent directory
:args List files
:args *.php Open file list
:grep expression *.php Returns a list of .php files contening expression
gf Open file name under cursor

和 Unix 系统交互

:!pwd Execute the pwd unix command, then returns to Vi
!!pwd Execute the pwd unix command and insert output in file
:sh Temporary returns to Unix
$exit Retourns to Vi

对齐

:%!fmt Align all lines
!}fmt Align all lines at the current position
5!!fmt Align the next 5 lines

Tabs/Windows

:tabnew Creates a new tab
gt Show next tab
:tabfirst Show first tab
:tablast Show last tab
:tabm n(position) Rearrange tabs
:tabdo %s/foo/bar/g Execute a command in all tabs
:tab ball Puts all open files in tabs
:new abc.txt Edit abc.txt in new window

分屏显示

:e filename Edit filename in current window
:split filename Split the window and open filename
ctrl-w up arrow Puts cursor in top window
ctrl-w ctrl-w Puts cursor in next window
ctrl-w_ Maximize current window vertically
ctrl-w| Maximize current window horizontally
ctrl-w= Gives the same size to all windows
10 ctrl-w+ Add 10 lines to current window
:vsplit file Split window vertically
:sview file Same as :split in readonly mode
:hide Close current window
:­nly Close all windows, excepted current
:b 2 Open #2 in this window

自动完成

Ctrl+n Ctrl+p (in insert mode) Complete word
Ctrl+x Ctrl+l Complete line
:set dictionary=dict Define dict as a dictionnary
Ctrl+x Ctrl+k Complete with dictionnary

Marks

m {a-z} Marks current position as {a-z}
' {a-z} Move to position {a-z}
'' Move to previous position

缩写

:ab mail mail@provider.org Define mail as abbreviation of mail@provider.org

文本缩进

:set autoindent Turn on auto-indent
:set smartindent Turn on intelligent auto-indent
:set shiftwidth=4 Defines 4 spaces as indent size
ctrl-t, ctrl-d Indent/un-indent in insert mode
>> Indent
<< Un-indent
=% Indent the code between parenthesis
1GVG= Indent the whole file

语法高亮

:syntax on Turn on syntax highlighting
:syntax off Turn off syntax highlighting
:set syntax=perl Force syntax highlighting

转载于:https://www.cnblogs.com/Felix-F/p/3256547.html

常用的130个vim命令相关推荐

  1. 20180929 VIM进入编辑模式、VIM命令模式常用操作

    2019独角兽企业重金招聘Python工程师标准>>> vim进入编辑模式方式 按键 作用 i 在当前字符前插入 I 在光标所在行的行首插入 a 在当前字符后插入 A 在光标所在行的 ...

  2. 130个你需要了解的VIM命令

    基础 :e filename Open filename for edition :w Save file :q Exit Vim :q! Quit without saving :x Write f ...

  3. linux中vim内容定位,Linux运维行走江湖必备之:vim命令常用参数

    原标题:Linux运维行走江湖必备之:vim命令常用参数 vim是Linux运维日常工作中最常用的命令之一,vim命令的参数有很多,我们选用一些常用的命令参数,足以对付日常的文本编辑工作,如果日后有需 ...

  4. 常用的vim命令总结

    vim就不多介绍了,很好用很强大.在windows下可以用gvim,配置一下_vimrc文件,再配合cscope和ctag等工具,就是一个功能强大的IDE. 常用的命令在这里总结下,以后忘了可以看看, ...

  5. 如何在Linux中运用vim命令轻松编辑文件

    在正文开讲之前,我们先来解决一个问题: 有很多人在Linux环境下操作时,有时在虚拟机中操作的内容我们无法将其移入真机中,我们可以用以下方式建立真机与虚拟机的联系,在真机中操作虚拟机. 1).ifco ...

  6. java 执行linux命令行_10个高效Linux技巧及Vim命令对比

    专注于Java领域优质技术,欢迎关注 作者:vimtutor 来自:Vim教程网 Vim的很多命令和功能与Linux系统的命令和功能及其相似,可以说是一脉相承.Vim教程网(https://vimjc ...

  7. 10个高效Linux技巧及Vim命令对比

    写在前面:今天没来得及唱歌~一个多星期没更新了,今天记录下我自己用得比较多的Linux命令行快捷键,小伙伴们别嘲笑我哈~不知道为啥,每次发文就有好几个小伙伴取消关注离开之前,可以告诉我为什么吗~~ V ...

  8. Linux 命令(34)—— vim 命令

    文章目录 1.简介 2.命令格式 3.选项说明 4.内置命令 5.vim 需知 5.1 vim 的四大模式 5.2 vim 相关编码选项 5.3 vim 读写文件时编码转换过程 6.vim 常见用法 ...

  9. 【重点】初窥Linux 之 我最常用的20多条命令

    [重点]初窥Linux 之 我最常用的20多条命令 玩过Linux的人都会知道,Linux中的命令的确是非常多,但是玩过Linux的人也从来不会因为Linux的命令如此之多而烦恼,因为我们只需要掌握我 ...

最新文章

  1. RPi 2B UART作为调试口或者普通串口
  2. 学习笔记(二)——CSS基础
  3. 读写分离后,数据库又遇到瓶颈
  4. SyntaxError: Missing parentheses in call to 'print'
  5. Spring 注入内部 Beans
  6. Linux mint 17中文输入法安装,改动linux mint与windows7双系统启动顺序
  7. 智己汽车——比智能车更豪华,比豪华车更智能
  8. 【python教程入门学习】两道关于递归的练习题
  9. Earth Wind and Fire CodeForces - 1148E (构造)
  10. mysql binlog限流问题总结
  11. tensorflow之train.get_checkpoint_state
  12. MySQL + Atlas --- 部署读写分离
  13. 168.Excel Sheet Column Title
  14. 如何通过 Redis 实现分布式锁
  15. 小米八显示无服务器,二修小米8无服务案例
  16. android svn新建分支,android studio中创建、切换svn分支
  17. 四六级英语听力软件测试,英语四六级听力真题库
  18. 算法设计-天下会评选一级弟子
  19. vb6使用WinRAR压缩和解压文件
  20. 中文拼音转换成CMU的音素工具

热门文章

  1. condest--1-范数的条件数估计
  2. 【Hexo】搭建自己的博客并到Github Pages
  3. 一个免费的页面素材网站
  4. 分布式文件系统HDFS练习
  5. socket与http
  6. 【工作感悟】——聊聊面试那些事
  7. 第三章、Data语意学
  8. javascript之function1
  9. Vector和LinkedList源代码阅读笔记
  10. 一位程序员的奋斗历程!------转载