I don't know what happened, just that :0 is supposed to bring you to
"line zero" (but since there is no such line, you get to the first line
instead).
Maybe there was a missing refresh?
Try opening your logfile in readonly mode (e.g. with :view rather than
:edit, :sview rather than :new, gview rather than gvim, view rather than
vim, etc.) and if you still have the problem, try Ctrl-L to redraw the
screen.
BTW, trying to write a single file from two processes at the same time
(such as Vim and the log-writing process) is courting disaster. If you
do, you're bound to get problems sooner rather than later.
Best regards,
Tony.
--
Alexander Graham Bell is alive and well in New York, and still waiting
for a dial tone.
You can debug by vim -V20/tmp/log (viml only).
And you can set cursor debugging (eg one sending bytes to terminal very
slowely), see :h writedelay. That's all I know about. Not sure whether
this is going to help you much though.
Marc Weber
Ah, OK. The fact that you talked about "editing" the logfile (not about
"viewing" it) made me think that you tried to modify it in Vim while the
program writing it was still running.
See:
:help -w
:help -V
and about the latter:
:help 'verbose'
:help 'verbosefile'
Best regards,
Tony.
--
Not far from here, by a white sun, behind a green star, lived the
Steelypips, illustrious, industrious, and they hadn't a care: no spats
in their vats, no rules, no schools, no gloom, no evil influence of the
moon, no trouble from matter or antimatter -- for they had a machine, a
dream of a machine, with springs and gears and perfect in every
respect. And they lived with it, and on it, and under it, and inside
it, for it was all they had -- first they saved up all their atoms,
then they put them all together, and if one didn't fit, why they
chipped at it a bit, and everything was just fine ...
-- Stanislaw Lem, "Cyberiad"
> Hi
> I had this strange behavior again this afternoon, so I was editing a
> file, that was being modified by a java process who was writing in it.
> And I don't know what happens (maybe a mousse scroll or something like
> that) and the whole part before the line is erased and I got :
> g`" instead.
>
> I have been able to take a picture with my phone (they are so paranoid
> in my firm that I avoided to make a screenshot sent by email) it can
> be seen here:
> http://www.flickr.com/photos/69121410@N06/6284304680/in/photostream/lightbox/
>
> I tried :redraw, CTrl-L nothing to do.
> The strange thing is that the file is not written, cause when I close
> it vim doesn't ask me if I want to save, and re-opening bring it back
> to me.
>
> Any ideas ?
To me it looks like it's a malfunctioning autocmd, which doesn't
anticipate being called when it's being called. (Pretty sure 'autoread'
doesn't kick in in Insert mode.)
As pointed out in:
:help g`
g`"
jumps to the last known position in a file. So, it's commonly added to
systemwide /etc/vimrc autocmds so that opening a file again will start
you in the same place you were at when you last stopped editing it.
A common example is included in the example rc, IIRC. On Gentoo, it's:
" [...inside augroup gentoo]
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
Not sure, but I think this one would be okay regardless of the context.
Maybe you have something simpler, like:
au BufReadPost * normal g`"
Or maybe you have some other command that tries to reread the buffer,
even when in Insert mode. (Which then triggers the bad behavior of the
other command.)
--
Best,
Ben
autocmd BufReadPost *\ if line("'\"") > 0 && line("'\"") <= line("$") |\ exe "normal g`\"" |\ endif
au BufReadPost * normal g`"
--You received this message from the "vim_use" maillist.Do not top-post! Type your reply below the text you are replying to.For more information, visit http://www.vim.org/maillist.php
> Hey Ben
>
>
> I think you give me the right hint I have this autocmd in my _vimrc
>
>
> autocmd BufReadPost *
> \ if line("'\"") > 0 && line("'\"") <= line("$") |
> \ exe "normal g`\"" |
> \ endif
>
>
> so is it replacable by the autocmd you gave
>
> au BufReadPost * normal g`"
>
No, that's not what I meant at all. I thought something simpler might
be making things worse, though in hindsight, I think it'd be about the
same.
I think the problem is something else that causes that autocmd to be
fired at the wrong time. I mentioned the 'autoread' option (which I
don't think will ever fire when you're in insert mode, but comes into
play with files that change on disk while you're editing). It seems
more likely to me that some other autocmd (possibly on the CursorMovedI
event?) might do something that would trigger a reload of changed files.
What plugins have you installed, or what other autocmds do you have?
--
Best,
Ben
set nocompatiblecd c:\devset nobackupset nowbset noswapfileset wildmenuset novbset wrapset numberset backspace=indent,eol,startset autoindentset smarttabset history=500set rulerset showcmdset incsearchset showbreak=\set cursorlineset cmdheight=3set so=10set visualbellset digraphset equalalwaysset splitbelowset hiddenset ignorecaseset noebset autowriteset ek noet nosolset fo=cqrtset shm=atset ww=<,>,h,lset comments=b:#,:%,n:>set novb"set list listchars=tab:»·,trail:·set su=.bak,~,.o,.h,.info,.swp,.obj,.dvi,.pdf,.log,.aux,.exe,.tar,.gz,.zip,.bz2,.exeset expandtabset sbset lines=40"Mappingsmap Q gqmap <F5> :ls<CR>map <F6> :bd<CR>map <F7> :bp<CR>map <F8> :bn<CR>map j gjmap <DOWN> gjmap k gkmap <UP> gkmap <F9> :make <CR>map :bd :bd!vnoremap p :let current_reg = @"gvs=current_reg" 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 onset hlsearchendif" 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" 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
endif " has("autocmd")" MS Windows Behavior shortcutssource $VIMRUNTIME\mswin.vimbehave mswin" Auto Commands" Placing Vim into the directory where the file is.autocmd VimEnter,BufNewFile,BufRead,BufEnter * if strlen (@%) !=0 | cd %:p:h | endifau VimEnter,BufNewFile,BufRead,BufEnter *.sql set ft=plsql" vim -b : edit binary using xxd-format!augroup Binaryau!au BufReadPre *.bin *.bqy let &bin=1au BufReadPost *.bin *.bqy if &bin | %!xxdau BufReadPost *.bin *.bqy set ft=xxd | endifau BufWritePre *.bin *.bqy if &bin | %!xxd -rau BufWritePre *.bin *.bqy endifau BufWritePost *.bin *.bqy if &bin | %!xxdau BufWritePost *.bin *.bqy set nomod | endifaugroup END
--Best,Ben
> Ben
>
> this is my _vimrc file:
>
> [...]
>
> " 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
Should be non-problematic.
> " vim -b : edit binary using xxd-format!
> augroup Binary
> au!
> au BufReadPre *.bin *.bqy let &bin=1
> au BufReadPost *.bin *.bqy if &bin | %!xxd
> au BufReadPost *.bin *.bqy set ft=xxd | endif
> au BufWritePre *.bin *.bqy if &bin | %!xxd -r
> au BufWritePre *.bin *.bqy endif
> au BufWritePost *.bin *.bqy if &bin | %!xxd
> au BufWritePost *.bin *.bqy set nomod | endif
> augroup END
All of those lines are wrong:
1. Should have commas between the patterns:
au {event} {pat},{pat} {command}
E.g.:
au BufReadPre *.bin *.bqy let &bin=1
Must be:
au BufReadPre *.bin,*.bqy let &bin=1
(better, make it local):
au BufReadPre *.bin,*.bqy let &l:bin=1
(shorter, but equivalently: [setl = setlocal])
au BufReadPre *.bin,*.bqy setl bin
2. You can't split the command between two autocmds the way you have.
au BufWritePre *.bin *.bqy if &bin | %!xxd -r
au BufWritePre *.bin *.bqy endif
Needs to be (along with correction #1):
au BufWritePre *.bin,*.bqy if &bin | %!xxd -r | endif
> What I have noticed is that it occurs on that java log file that are
> being written while edited, and on where I often do string search.
Do your *.bin files change while you're editing them? Maybe you're
hitting those malformed autocmds. Unfortunately, otherwise, nothing
jumps out at me. You're under Windows? What version? What version of
Vim?
--
Best,
Ben
On Thu, 27 Oct 2011, Eddine wrote:
--
Best,
Ben