English 中文(简体)
Vim:如何恢复治疗师的逻辑和实际立场?
原标题:Vim: how to restore the cursor s logical and physical positions?
  • 时间:2012-01-13 17:04:24
  •  标签:
  • vim

How to restore the cursor s "logical" and "physical" positions when I open a file ?

:

  1. cur应当放在档案中最后的逻辑上。

  2. cur应当按照正门窗在最后一刻的物理线上。

http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session”rel=“nofollow noreferer”>。 它确实将 cur放在正确的逻辑上。 但是,窗户的曲线位置是第一线或中线。

UPDATE: The solution is mkview and loadview as noted by @sehe.

To make it work with other plugins (in my case, latex file + latex-box), the following would be useful:

www.un.org/Depts/DGACM/index_spanish.htm 页: 1

au VimEnter *.tex loadview

缩略语

  • After doing all the startup stuff, including loading .vimrc files, executing the "-c cmd" arguments, creating all windows and loading the buffers in them.

www.un.org/Depts/DGACM/index_spanish.htm 2. 更好地或想象“概览-快递”

通过创建“圆形码”-~/.vim/view,你将在那里保存所有“概览-snapshot-files”。

If you are using git to synchronize ~/.vim across computers, maybe you d like to

  • ignore the files in ~/.vim/view,
  • but keep the empty folder in your repo.

然后,您需要(根据回答here)

  • create a empty file: ~/.vim/view/.gitignore
  • put view/*, and !.gitignore in ~/.vim/.gitignore
最佳回答

Good news, :mkview 已经这样做(见以下文件节选)。

更具体地说,<代码>:>恢复滚动状态和组装状态,viewoptions 包括cursor, pages

更糟糕的消息是,如果你希望的话,你可以透明地让大家对公开档案发表意见。 举例来说,为了便于查阅所有来源文件,在MYVIMRC中增加:

au BufWinLeave *.c mkview
au BufWinEnter *.c silent loadview

<><>Edit>/strong> 根据香港的评论,加上某些假想,如果你使用<代码>VimEnter自动指令装载该观点,则会更好。

选择使用<代码>viewdir,确定保存意见的地点。

<>m>Beure to also look at :mksession,因为它更为强大,因为它能够恢复多个窗口、表格及其位置、绘图、登记、选择、文件夹等。 页: 1

How it works

Vim :mkview a. 修复以下地点:

silent! normal! zE
let s:l = 88 - ((4 * winheight(0) + 4) / 9)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
88
normal! 025l

只是这些指挥来源,就像任何手稿一样。

From the docs

<><>>>>> http://www.em>cfalls/em>。

                            *:mkvie* *:mkview*
:mkvie[w][!] [file] Write a Vim script that restores the contents of the
            current window.
            When [!] is included an existing file is overwritten.
            When [file] is omitted or is a number from 1 to 9, a
            name is generated and  viewdir  prepended.  When the
            last directory name in  viewdir  does not exist, this
            directory is created.
            An existing file is always overwritten then.  Use
            |:loadview| to load this view again.
            When [file] is the name of a file ( viewdir  is not
            used), a command to edit the file is added to the
            generated file.

The output of ":mkview" contains these items:
1. The argument list used in the window.  When the global argument list is
   used it is reset to the global list.
   The index in the argument list is also restored.
2. The file being edited in the window.  If there is no file, the window is
   made empty.
3. Restore mappings, abbreviations and options local to the window if
    viewoptions  contains "options" or "localoptions".  For the options it
   restores only values that are local to the current buffer and values local
   to the window.
   When storing the view as part of a session and "options" is in
    sessionoptions , global values for local options will be stored too.
4. Restore folds when using manual folding and  viewoptions  contains
   "folds".  Restore manually opened and closed folds.
5. The scroll position and the cursor position in the file.  Doesn t work very
   well when there are closed folds.
6. The local current directory, if it is different from the global current
   directory.
问题回答

暂无回答




相关问题
Autoupdate VIM Plugins?

Is it possible to update vim plugins automatically?

how to unindent in vim without leaving edit mode?

I m writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block....

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

Vim - Deleting XML Comments

How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread ...

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the ...

Profiling Vim startup time

I’ve got a lot of plugins enabled when using Vim – I have collected plugins over the years. I’m a bit fed up with how long Vim takes to start now, so I’d like to profile its startup and see which of ...

热门标签