Yakov Lerner wrote:
On 10/7/06, Bram Moolenaar <[EMAIL PROTECTED]> wrote:

Yakov Lerner wrote:

> I suggest new flag for 'viminfo'; flag to turn on the *last-position-jump*
> functionality (say, letter j). Such it will be much easier method to
> turn on the last-position-jump functionality. With new flag, it will be mere:
>
>       :set viminfo='20,<50,s10,j
> or
>       :set viminfo+=j
> -- as easy as addding flag j to 'viminfo'.
>
> Currently, the magic sequence to turn on the *last-position-jump*
>
>   :set viminfo='20,<50,s10
>   augroup lastPositionJump
>   au!
> autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") |
>     \   exe "normal g`\"" |endif
>   augroup END
>
> This proves difficult for novice vim user to figure out even with the
> help of vimhelp.
> It's demanded and requested features, why not to make it easier to turn on ?
>
> I mean that internally, new flag would add/remove that same autocmd.
> It's not difficult to implement, right ? And it's backward-compatible.
> Can I make a patch ?

I think finding the "j" flag in the 'viminfo' option is much harder than
finding the hint to source the $VIMRUNTIME/vimrc_example.vim script.

Also keep in mind that sometimes jumping to some position is undesired,
thus we would also need a mechanism to disable it.

Of course, 'set viminfo-j' would remove the autocommand
(like augroup lastPositionJump|au!|augroup END).

But maybe 'set autojump' then ? (With 'noautojump' removing the
autocommand ?

Every time I look at the {autocmd BufReadPost *    \ if line("'\"") >
0 && line("'\"") <= line("$") | exe "normal g`\"" |endif} sequence , I
get
a feeling like the switch which would need to be acessible and
reachable inside the car near the driver seat, was palced under
the hood near the engine, and when one needs to access it,
you need to get out of the car and open the hood.

Yakov


To deactivate it,

        au! vimrcEx BufRead

Reactivating it is of course a little trickier, especially if you want to be able to re-disable it.

I suggest the following, in $VIMRUNTIME/vimrc_example.vim

        function s:EnableCursorSet()
                augroup vimrcEx
                        au! BufRead *
                        \ if line("'"") > 0 && line("'"") <= line("$") |
                          \ exe "normal g`\"" |
                        \ endif
                augroup END
        endfunction
        command -nargs=0 -bar CursorSetOn call s:EnableCursorSet()
        command -nargs=0 -bar CursorSetOff au! vimrcEx BufRead
        cabbrev CSon CursorSetOn
        cabbrev CSoff CursorSetOff

This creates two commands, CursorSetOn and CursorSetOff. Better command names may perhaps be found but you get the drift. The autocommand group "vimrcEx" is already used for the autocommands defined by the vimrc_example.vim.

The above would also have the advantages of requiring zero change to the C code, and of upward compatibility.

Bram: The vimrc_example.vim is already mentioned in 23 helpfile lines. I suggest that (a) it be mentioned also under ":help vimrc" and (b) that the text under ":help not-compatible" be changed to mention sourcing rather than (as now) copying. Sourcing is not really more complicated than copying, it is a Vim thing, and it is done the same way on all platforms:

Example text (as a replacement for lines 57-90 of usr_01.txt dated 2006 Aug 22):
---- 8< ----
                                                        *not-compatible*
The manuals often assume you are using Vim with Vi-compatibility switched
off.  For most commands this doesn't matter, but sometimes it is important,
e.g., for multi-level undo, or for continuation lines in scripts.  An easy way
to make sure you are using the right setup, is to invoke the example vimrc
file.  By doing this inside Vim you don't have to check out where it is
located.  To do this, open your |vimrc| by doing

on Dos/Windows: >
        :e ~/_vimrc

on other systems: >
        :e ~/.vimrc

then, at or near the top of the file, enter the line >

        runtime vimrc_example.vim

Save your work with >

        :wq

If you start Vim now, the 'compatible' option should be off.  You can check it
with this command: >

        :verbose set compatible?

If Vim responds with "nocompatible" you are doing well.  If the response is
"compatible" you are in trouble.  You will have to find out why the option is
still set.  Perhaps the file you wrote above is not found.  Use this command
to find out: >

        :scriptnames

If your file is not in the list, check its location and name.  If it is in the
list, there must be some other place where the 'compatible' option is switched
back on.  The second line (if present) of the reply to ":verbose set
compatible?" will tell you which script set the option latest. There will be
no second line if the option is still at its default, or if you set it
yourself at the command-line.

For more info see |vimrc| and |compatible-default|.
---- >8 ----


Best regards,
Tony.

Reply via email to