Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1175730
  • 博文数量: 115
  • 博客积分: 950
  • 博客等级: 准尉
  • 技术积分: 1734
  • 用 户 组: 普通用户
  • 注册时间: 2011-12-08 20:46
文章分类

全部博文(115)

文章存档

2015年(5)

2014年(28)

2013年(42)

2012年(40)

分类: LINUX

2013-09-22 18:11:31

Ref:  vim 如何刷新或重载reload 已打开的文件

Just use

   :e

to reload the file.  I believe, if you've made changes to the
file, it requires you to do

   :e!

to force-discard your local changes and reload from the disk.

If I'm not sure, I'll often yank my current copy into a scratch
buffer/window, force-reload the file from disk, and then use

   :diffthis

on each of the two buffers/windows to verify that there are no
surprises.

You may also be interested in the 'autoread' setting.

More information at

   :help FileChangedShell
   :help 'autoread'
   :help :e
   :help :diffthis

-tim



I have found, that the most comfortable way to do this is
DiffOrig command, described in the VIM help (you should define it
self though). One this command does the something very similar to
all those copy/paste/force reload/diffthis stuff.

:help DiffOrig



To reload unconditionally, from wherever it is, the file you're
curretly editing:
        :e    " read-write if the file has read-write permissions
or
        :view    " always readonly

- To check whether any of the file(s) you're currently editing has been
changed by someone else:
        :checkt[ime]

If a file or its datestamp have changed, then if 'autoread' is set and
the file is not 'modified' in your instance of Vim, Vim will reload it
without prompting. Otherwise, Vim will ask you what you want to do about
the change.

See
        :help :edit
        :help :checktime
        :help 'autoread'




Random; but I liked this command; so wrote a little wrapper to toggle it... (broken if you change buffers I know, but my scripting is horrible at best for vim)

function! DiffOrig()
    if &diff
        wincmd p | bdel | diffoff
    else
        vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis
    endif
endfunction
map do :call DiffOrig()
阅读(24269) | 评论(0) | 转发(0) |
0

上一篇:Vim正则表达式

下一篇:xp 误删逻辑分区

给主人留下些什么吧!~~