End of lines not remembered with gvim Easy on Windows

20 views
Skip to first unread message

Jean Johner

unread,
Mar 28, 2010, 5:41:07 AM3/28/10
to vim_dev
Hello,
Please launch gvim Easy on Windows with Start/All programs/Vim 7.2/
gvim Easy, then open file1.
Put the cursor at end of line 10 (say column 24)
Quit
Reopen file1 in the same way
Result: the cursor is on line 10, column 23.

It does not seem to be so easy to solve (see thread "How to remember
end of line when quitting/reopening in insert mode" on vim_use).

Best regards
Jean Johner

Christian Brabandt

unread,
Mar 28, 2010, 8:30:16 AM3/28/10
to vim_dev
Hi Jean!

As I said in the thread on vim_use, it depends how you quit vim. If you
use <ctrl-O> you will move the cursor. So the cursor will be in column
23 when quitting. If you reopen the file, the cursor will be correctly
positioned on the last column.

If you quit, by clicking the menu, that's basically the same issue. The
menu is constructed by means of :amenu. If you read the help, you'll
see, that for insert mode, amenu will insert <ctrl-o> before any
command, it is executing.

The solution is to use <c-\><c-o> before issuing the command (see :h
i_CTRL-\_CTRL-O). I am not sure, why amenu uses <C-\><C-O> instead of
<C-O>, but I suspect, there is a reason for that. In case it is not, I
quickly hacked together this patch (attached), which seems to work.


regards,
Christian

patch2

Christian Brabandt

unread,
Mar 28, 2010, 8:39:36 AM3/28/10
to vim_dev
Hi vim_dev!

On So, 28 M�r 2010, Christian Brabandt wrote:

> <C-O>, but I suspect, there is a reason for that. In case it is not, I
> quickly hacked together this patch (attached), which seems to work.

Hm, I am not sure, why git included that stuff in eval.c into the patch.
This was supposed to be a fresh HEAD and I only modified menu.c So
resending a clean patch.


Mit freundlichen Gr��en
Christian
--
Altsein hei�t f�r mich immer: F�nfzehn Jahre �lter als ich.
-- Bernard Mannes Baruch

patch2

Bram Moolenaar

unread,
Mar 28, 2010, 10:34:13 AM3/28/10
to Jean Johner, vim_dev

Jean Johner wrote:

> Please launch gvim Easy on Windows with Start/All programs/Vim 7.2/
> gvim Easy, then open file1.
> Put the cursor at end of line 10 (say column 24)
> Quit
> Reopen file1 in the same way
> Result: the cursor is on line 10, column 23.

Well, that's almost right.

> It does not seem to be so easy to solve (see thread "How to remember
> end of line when quitting/reopening in insert mode" on vim_use).

It's nearly impossible to change without side effects. I don't think
it's worth spending much time on.

--
Kisses may last for as much as, but no more than, five minutes.
[real standing law in Iowa, United States of America]

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Jean Johner

unread,
Mar 28, 2010, 5:32:03 PM3/28/10
to Christian Brabandt, vim...@googlegroups.com
On Mar 28, 2:30 pm, Christian Brabandt <cbli...@256bit.org> wrote:

> The solution is to use <c-\><c-o> before issuing the command (see :h
> i_CTRL-\_CTRL-O). I am not sure, why amenu uses <C-\><C-O> instead of
> <C-O>, but I suspect, there is a reason for that. In case it is not, I
> quickly hacked together this patch (attached), which seems to work.

Hi Christian,
1) In unix
- With vimrc_example.vim as .vimrc, quitting with <C-\><C-O>:q does
not solve the problem.
- With vimrc_example.vim completed with Andy's code, quitting with <C-
\><C-O>:q does solve the problem

2) In Windows
Typing CTRL-\ writes an \ so it does not work.

For unix, I guess your patch +Andy's code+using <C-\><C-O>:q to quit
would completely solve the problem. I have not tried yet.

Best regards
Jean Johner

Jean Johner

unread,
Mar 28, 2010, 5:36:22 PM3/28/10
to vim_dev
On Mar 28, 4:34 pm, Bram Moolenaar <B...@Moolenaar.net> wrote:

> Well, that's almost right.
>

> It's nearly impossible to change without side effects.  I don't think
> it's worth spending much time on.

You are right, may be I am a perfectionist. But Chritian and Andy are
too ...

Best regards
Jean Johner

Tony Mechelynck

unread,
Mar 28, 2010, 8:43:59 PM3/28/10
to vim...@googlegroups.com, Jean Johner
On 28/03/10 23:32, Jean Johner wrote:
> On Mar 28, 2:30 pm, Christian Brabandt<cbli...@256bit.org> wrote:
>
>> The solution is to use<c-\><c-o> before issuing the command (see :h
>> i_CTRL-\_CTRL-O). I am not sure, why amenu uses<C-\><C-O> instead of
>> <C-O>, but I suspect, there is a reason for that. In case it is not, I
>> quickly hacked together this patch (attached), which seems to work.
>
> Hi Christian,
> 1) In unix
> - With vimrc_example.vim as .vimrc, quitting with<C-\><C-O>:q does
> not solve the problem.
> - With vimrc_example.vim completed with Andy's code, quitting with<C-
> \><C-O>:q does solve the problem
>
> 2) In Windows
> Typing CTRL-\ writes an \ so it does not work.

This just means that to get the Ctrl-\ character (0x1C) on Windows, you
have to do something else than hit \ while holding Ctrl. Try the following:

:map <F12> <C-\>
:map! <F12> <C-\>

then hit F12 whenever you need a Ctrl-\ (in any mode). Using map rather
than noremap means that any mapping which includes <C-\> in its {lhs}
will still be applied.

Of course you can use any other convenient {lhs} instead of <F12> if you
prefer; and if you like uniformity you can define (and use) these
mappings even on systems where "hitting \ while holding Ctrl" does work.

Another possibility would be to find which key combo (if any) produces
the byte 0x1C on your Windows keyboard. On my (Belgian) AZERTY keyboard,
and on Linux, I get it by holding both Ctrl and AltGr down while hitting
the key at bottom left, between Shift and W. Not exactly the easiest
thing to do.

>
> For unix, I guess your patch +Andy's code+using<C-\><C-O>:q to quit
> would completely solve the problem. I have not tried yet.
>
> Best regards
> Jean Johner
>

Best regards,
Tony.
--
Fortune's graffito of the week (or maybe even month):

Don't Write On Walls!

(and underneath)

You want I should type?

Reply all
Reply to author
Forward
0 new messages