ubuntu 8.04 vim问题请教

Vim、Emacs配置和使用
回复
luofuchong
帖子: 9
注册时间: 2007-11-06 10:02
送出感谢: 0
接收感谢: 0

ubuntu 8.04 vim问题请教

#1

帖子 luofuchong » 2009-01-08 23:04

各位大哥,小弟最近在使用ubuntu-8.04的时候碰到一个vim的问题:

以前使用vim的时候,关闭文件后,下次重新打开,光标会停留在上一次的编辑位置;以前的搜索记录也是可以翻查到的。

升级ubuntu-8.04后,安装好vim,拷贝以前的vim配置文件,发现vim的历史记录功能不见了。

请问有没大虾碰到过类似的问题,请问如何解决?感激不尽!
头像
ws_105
帖子: 313
注册时间: 2008-10-24 8:02
送出感谢: 0
接收感谢: 0

Re: ubuntu 8.04 vim问题请教

#2

帖子 ws_105 » 2009-01-09 10:49

你的 .vimrc 文件中有下面的代码吗?

代码: 全选

" Jump to the last position when reopening a file
if has("autocmd")
    au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") 
                \| exe "normal g'\"" | endif
endif
Ubuntu 8.04 @ Intel Pentium D 925 + Intel 945G Chipset + DDR2 1.0G + SATA 160G
http://hi.baidu.com/ws_105
sarrow
帖子: 403
注册时间: 2007-10-27 1:04
送出感谢: 0
接收感谢: 1 次

Re: ubuntu 8.04 vim问题请教

#3

帖子 sarrow » 2009-01-09 14:35

`1,`2, ... `0

vim内部支持记录10个最近打开文件的直接访问,“`”再加一个数字就可以了。

你还可以安装MRU.vim,用起来更方便一些。
luofuchong
帖子: 9
注册时间: 2007-11-06 10:02
送出感谢: 0
接收感谢: 0

Re: ubuntu 8.04 vim问题请教

#4

帖子 luofuchong » 2009-01-09 22:18

首先感谢两位的回复

1、to ws_105:
我的vim配置文件有你提到的选项,在公司的电脑(7.04)上一直用得好好的(我顺便把它贴出来,你可以帮忙看看^_^)

2、to sarrow:
引:
“`1,`2, ... `0

vim内部支持记录10个最近打开文件的直接访问,“`”再加一个数字就可以了。“

请问你指的是?可以说的详细点吗,谢谢。

3、以下是我的vim配置文件:
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2002 Sep 19
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

"if has("vms")
set nobackup " do not keep a backup file, use versions instead
"else
" set backup " keep a backup file
"endif

set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" set nu
set fencs=utf-8,ucs-bom,euc-jp,gb18030,gbk,gb2312,cp936
set viminfo='1000,<500

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")

" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
" filetype plugin indent on

" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!

" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78

" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif

augroup END

else

set autoindent " always set autoindenting on

endif " has("autocmd")

注:
我的vim是完全安装的:sudo apt-get install vim-full
luofuchong
帖子: 9
注册时间: 2007-11-06 10:02
送出感谢: 0
接收感谢: 0

Re: ubuntu 8.04 vim问题请教

#5

帖子 luofuchong » 2009-01-14 20:34

问题解决:
.viminfo的权限问题(大概第一次使用vim的时候加入了sudo,.viminfo的权限为root,所以普通用户的历史记录无法写入导致)
回复

回到 “Vim和Emacs”