Wednesday, October 26, 2011

Re: Tracing Vim into a log file.

Ben
 
this is my _vimrc file:
 
set nocompatible
cd c:\dev
set nobackup
set nowb
set noswapfile
set wildmenu
set novb
set wrap
set number
set backspace=indent,eol,start
set autoindent
set smarttab
set history=500
set ruler
set showcmd
set incsearch
set showbreak=\
set cursorline
set cmdheight=3
set so=10
set visualbell
set digraph
set equalalways
set splitbelow
set hidden
set ignorecase
set noeb
set autowrite
set ek noet nosol
set fo=cqrt
set shm=at
set ww=<,>,h,l
set 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,.exe
set expandtab
set sb
set lines=40
 
"Mappings
map Q gq
map <F5> :ls<CR>
map <F6> :bd<CR>
map <F7> :bp<CR>
map <F8> :bn<CR>
map j gj
map <DOWN> gj
map k gk
map <UP> gk
map <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 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
" 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 shortcuts
source $VIMRUNTIME\mswin.vim
behave mswin
" Auto Commands
" Placing Vim into the directory where the file is.
autocmd VimEnter,BufNewFile,BufRead,BufEnter * if strlen (@%) !=0 | cd %:p:h | endif
au VimEnter,BufNewFile,BufRead,BufEnter *.sql set ft=plsql
" 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
 
 
 
 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.
Maybe I can force the readonly mode for those file as a workarround.
 
Thanks a lot for your help.
 
Eddine.
 
  
2011/10/27 Benjamin R. Haskell <vim@benizi.com>
 
On Wed, 26 Oct 2011, Eddine wrote:
 
 
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
 
--
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
 
 

--
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

No comments: