Auto-Reload Your Vimrc
来源:互联网 发布:贵州发展大数据带动 编辑:程序博客网 时间:2024/06/10 19:33
本文转载至:http://www.bestofvim.com/tip/auto-reload-your-vimrc/
If you're going to master Vim, you're going to spend some time tweaking & tailoring your.vimrc
file. And when you're doing that you'll want to see the effects of any changes as quickly as possible.
It's easy to get Vim to reload the .vimrc
file whenever it changes. Just add this to your.vimrc
file:
augroup reload_vimrc " { autocmd! autocmd BufWritePost $MYVIMRC source $MYVIMRCaugroup END " }
Save, then try it out. Put set number
at the bottom of your .vimrc
& save. Then change it to set nonumber
and save again. Line numbering should pop in an out. Instant reloading.
Breakdown
Let's take a look at what's happening. The bulk of the work's done by the line:
autocmd BufWritePost $MYVIMRC source $MYVIMRC
$MYVIMRC
is the platform-independent location of your .vimrc
file. So this command says that whenever that file is written, source (reload) it immediately afterwards.
The rest of the code, the wrapping, is a pattern you'll see a lot in .vimrc
files:
augroup somename " { autocmd! ...augroup END " }
This is housekeeping. Putting the commands in a group, and starting with autocmd!
clears out any previous autocommands Vim has registered for that group. If we didn't do this, Vim would append a new autocommand every time we wrote the .vimrc
file. Pretty quickly we'd have dozens of source $MYVIMRC
commands queued up for every single write.
See :help $MYVIMRC
, :help source
and especially :help autocmd
for more.
Plus: Steve Losh's excellent Learn Vimscript The Hard Way has a great explanation of how autocommand groups work.
- Auto-Reload Your Vimrc
- lein auto reload 异常
- tips for configuring your .vimrc
- .vimrc with auto file header for java
- 有关struts-config.xml auto reload 的问题
- Reload
- reload
- spring boot--creating your own auto-configuration
- vimrc
- .vimrc
- vimrc
- ~/.vimrc
- .vimrc
- .vimrc
- ~/.vimrc
- vimrc
- vimrc
- vimrc
- Java复习笔记-第四部分
- fpga中add ip核的输出截位问题
- 一些细节吧(随时更新)
- 你真的了解visible属性吗
- ANSI C和POSIX
- Auto-Reload Your Vimrc
- hdu 1536 OR poj 2960 S-Nim 博弈论,,求出SG'函数就可以解决
- 对NSOperation/NSOperationQueue的理解
- X的二进制长度
- 星星,停靠模式
- 问题解决索引20150226
- 固定主角出生点——对象层的使用
- Android 开发学习小结
- 手动创建和挂载swap 分区