vim高级用法
http://vim.wikia.com/wiki/Using_command-line_history
---------------------------------------------------------------------------------
When you press : to enter a command, or / to start a search, you often want to edit a previous command or search. That can be done using the up and down arrow keys to scroll through the history. Then you can edit a previous line. :help :
For example, type :s and then press the up arrow key. The last command that starts with exactly what you typed will be displayed. Scroll through the history by pressing up or down. There is a history for commands, and another for searches (and more :help history). You can list the entire history using the :history command (:help :history). The command :his lists the command history, and :his / lists the search history.
In many situations, a better solution is the command-line window which you can open in two ways:
- Type
q:for commands, orq/for searches; or - Type
:or/to start entering a command or search, then press the 'cedit' key (default is Ctrl-f :help 'cedit').
The advantage of the command-line window is that you can use all Vim's editing power, including searching with '/' in normal mode, or using whole-line completion (:help compl-whole-line) in insert mode. After editing a command, you can:
- Press Enter to execute the current line (and close the command-line window); or
- Press Ctrl-c twice to close the command-line window (cancel).
Contents
[show]
Details
Edit
Suppose you search for "horse", then for "Hello", then for "helium", then for "habit".
If you type /h and repeatedly press up arrow, you will see /habit, then /helium, then /horse ("Hello" is skipped because the history navigation is case-sensitive and "Hello" does not start with a lowercase "h").
Register : holds the last command, and / holds the last search. Therefore ":p will paste the last command, and "/p will paste the last search.
Type @: to repeat the last command.
You may have used several commands (for example, :%s/old/new/g) on the current buffer, and now find you would like to repeat those commands on another buffer. Type q: to enter the command window, then select and yank the commands you want. Press Ctrl-c twice to close the command window. If wanted, you can paste the commands into a buffer, then edit and save them. Later, you can source the file containing the commands, or you can yank the commands, then type :@"<CR> to execute the yanked commands on the current buffer.
If you always want to use the command editing window, try these mappings:
nnoremap : q:i
nnoremap / q/i
nnoremap ? q?i
Keeping the window open
Edit
Executing a command closes the window but sometimes you want it to remain open.
Under :help q: we find a suggestion to map a key such as F5 to execute the current line, then re-open the command window: :autocmd CmdwinEnter * nnoremap <buffer> <F5> <CR>q:
This can be expanded to put us back on the same line in the command window, which is useful when repeating a whole series of commands. We use a global variable to remember which line we were on (buffer-local variables are lost when the window closes).
:autocmd CmdwinEnter * nnoremap <buffer> <F5> :let g:CmdWindowLineMark=line(".")<CR><CR>q::execute "normal ".g:CmdWindowLineMark."G"<CR>
References
Edit
- :help history
- :help Cmdline
- :help cmdwin
- :help 'cmdwinheight' option controls initial height of command-line window
- :help 'history' option controls number of history items stored in
viminfo
Comments
Edit
TO DO
- Fix Enhanced command window (or delete it if not helpful). If keep, add it as a "see also" here.
- The standard way to close the command-line window is with :q, or <C-W>q, or any of the standard "close this window" commands --- not with double Ctrl-C.
- What is the history file called? Where is it stored?
-
- The command window is not associated with a file at all. It is populated at startup from the .viminfo file, however. That may be worth mentioning somewhere...and the option to disable this
vim高级用法的更多相关文章
- 使用wget做站点镜像及wget的高级用法
本文为大家介绍 使用wget做站点镜像及wget的高级用法,供大家学习参考. # wget -r -p -np -k http://xxx.edu.cn -r 表示递归下载,会下载所有的链接,不过要注 ...
- vim/vi用法总结
第一章:安装: 在命令行运行vim,如果找不到程序,需要自己安装. 1.1 下载 从官方网站ftp://ftp.vim.org/pub/vim/unix/中选择一个版本下载,我这里使用的是vim-7. ...
- redis的Linux系统安装与配置、redis的api使用、高级用法之慢查询、pipline事物
今日内容概要 redis 的linux安装和配置 redis 的api使用 高级用法之慢查询 pipline事务 内容详细 1.redis 的linux安装和配置 # redis 版本选择问题 -最新 ...
- Visual Studio 宏的高级用法
因为自 Visual Studio 2012 开始,微软已经取消了对宏的支持,所以本篇文章所述内容只适用于 Visual Studio 2010 或更早期版本的 VS. 在上一篇中,我已经介绍了如何编 ...
- SolrNet高级用法(分页、Facet查询、任意分组)
前言 如果你在系统中用到了Solr的话,那么肯定会碰到从Solr中反推数据的需求,基于数据库数据生产索引后,那么Solr索引的数据相对准确,在电商需求中经常会碰到菜单.导航分类(比如电脑.PC的话会有 ...
- sqlalchemy(二)高级用法
sqlalchemy(二)高级用法 本文将介绍sqlalchemy的高级用法. 外键以及relationship 首先创建数据库,在这里一个user对应多个address,因此需要在address上增 ...
- Solr学习总结(六)SolrNet的高级用法(复杂查询,分页,高亮,Facet查询)
上一篇,讲到了SolrNet的基本用法及CURD,这个算是SolrNet 的入门知识介绍吧,昨天写完之后,有朋友评论说,这些感觉都被写烂了.没错,这些基本的用法,在网上百度,资料肯定一大堆,有一些写的 ...
- 再谈Newtonsoft.Json高级用法
上一篇Newtonsoft.Json高级用法发布以后收到挺多回复的,本篇将分享几点挺有用的知识点和最近项目中用到的一个新点进行说明,做为对上篇文章的补充. 阅读目录 动态改变属性序列化名称 枚举值序列 ...
- Jquery remove 高级用法
Jquery remove 高级用法 html 代码 <div class="file-image">abc1111</div><div class= ...
随机推荐
- jQueryUI常用功能实战
本系列文章导航 从零开始学习jQuery (一) 开天辟地入门篇 从零开始学习jQuery (二) 万能的选择器 从零开始学习jQuery (三) 管理jQuery包装集 从零开始学习jQuery ( ...
- Asp.net core使用IIS在windows上进行托管
摘要 最近项目中,尝试使用asp.net core开发,在部署的时候,考虑现有硬件,只能部署在windows上,linux服务器暂时没有. 部署注意事项 代码中启用iis和Kestrel public ...
- SNK 与PFX
snk 1用来证明这个生成的程序集是你发布的: 2如果你写的程序集要用在多个应用程序上的话,那么这个程序集必须要拥有唯一的名称,这个强名称是程序集唯一名称的一部分. 3只要你保护好你的snk文件不要公 ...
- NSArray进行汉字排序
由于NSArray并不直接支持对汉字的排序,这就要通过将汉字转换成拼音完毕按A~Z的排序,这看起来是个头疼的问题.由于牵扯到汉字转为拼音,kmyhy给出一个较易实现的方法,获取汉字的首字的首字母,如将 ...
- win10如何彻底删除Gis|彻底卸载ArcGis的方法说明
ArcGIS产品线为用户提供一个可伸缩的,全面的GIS平台.ArcObjects包含了许多的可编程组件,从细粒度的对象(例如单个的几何对象)到粗粒度的对象(例如与现有ArcMap文档交互的地图对象)涉 ...
- 泛泰A860(高通8064 cpu 1080p) 刷4.4专用中文recovery TWRP2.7.1.2版(三版通刷)
欢迎关注泛泰非盈利专业第三方开发团队 VegaDevTeam (本team 由 syhost suky zhaochengw(z大) xuefy(大星星) tenfar(R大师) loogeo cr ...
- Git:一本书 + 一个站点,让你掌握 Git
一本书:<<Pro Git in Chinese>> 一个网站:http://pcottle.github.io/learnGitBranching/
- 从零开始写一个发送h264的rtsp服务器(上)
转自:http://blog.csdn.net/jychen105/article/details/47006345 一.什么是RTSP 通常所说的rtsp协议其实包含三个协议: rtsp协议, rt ...
- 来自Google的TCP BBR拥塞控制算法解析
转自:http://blog.csdn.net/dog250/article/details/52830576 写本文的初衷一部分来自于工作,更多的来自于发现国内几乎还没有中文版的关于TCP bbr算 ...
- 详细解读LruCache类
LruCache是android提供的一个缓存工具类,其算法是最近最少使用算法.它把最近使用的对象用“强引用”存储在LinkedHashMap中,并且把最近最少使用的对象在缓存值达到预设定值之前就从内 ...