免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 19549 | 回复: 9

求助,vim回到上次光标位置 [复制链接]

论坛徽章:
0
发表于 2007-12-05 13:58 |显示全部楼层
不知道怎么了,我的vim
每次vim 一个文件,光标都在最上面的位置,不是上次我编辑的位置了..
有人知道为什么吗?
有什么办法恢复吗?
急呀...please help me !

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
发表于 2007-12-05 14:04 |显示全部楼层
进入vim后键入:
'0
即回到当初你编辑的位置
PS: 如果想把光标停止在指定的行, 这样
vim +n urfile // n为行号
如果要停留在行尾, 这样
vim + urfile

[ 本帖最后由 寂寞烈火 于 2007-12-5 14:07 编辑 ]

论坛徽章:
0
发表于 2007-12-05 14:16 |显示全部楼层
不是这个意思,
你是说恢复上次编辑文件吧,
我是说 vim file, 光标回到file上次退出的位置..

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
发表于 2007-12-05 14:23 |显示全部楼层

论坛徽章:
0
发表于 2007-12-05 14:27 |显示全部楼层
这里没找到解决的方法呀
继续救助!!!!!!!!

论坛徽章:
0
发表于 2007-12-05 15:52 |显示全部楼层
9. The viminfo file                             *viminfo* *viminfo-file* *E136*
                                                *E575* *E576* *E577*
If you exit Vim and later start it again, you would normally lose a lot of
information.  The viminfo file can be used to remember that information, which
enables you to continue where you left off.

This is introduced in section |21.3| of the user manual.

The viminfo file is used to store:
- The command line history.
- The search string history.
- The input-line history.
- Contents of non-empty registers.
- Marks for several files.
- File marks, pointing to locations in files.
- Last search/substitute pattern (for 'n' and '&').
- The buffer list.
- Global variables.

论坛徽章:
0
发表于 2007-12-05 15:58 |显示全部楼层
我有viminfo 这个文件呀..
是不是要配置??????

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
发表于 2007-12-05 16:02 |显示全部楼层
原帖由 amaorn 于 2007-12-5 15:58 发表
我有viminfo 这个文件呀..
是不是要配置??????

type
:marks

论坛徽章:
0
发表于 2007-12-05 16:07 |显示全部楼层
ok 搞定了,
c++ 板块的flw给了我答案

70 " 打开文件时,按照 viminfo 保存的上次关闭时的光标位置重新设置光标
71 au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

在.vimrc里添加!!

论坛徽章:
0
发表于 2011-12-29 21:57 |显示全部楼层
原来是这么设置的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP