> Hi Agathoklis,
>
> Agathoklis D. Hatzimanikas a écrit :
> > > You can try the following (substitute the path to the file you
> > > want to save your records):
> > >
> > > function! RecordFileOpen()
> > > let record = "\t(".strftime("%F %T").")\t/Users/remi/".expand("%:t").".txt"
> > > redir>> /path/to/file
> > > echo record
> > > redir END
> > > endfunction
>
> It worked almost perfectly! I modified it a bit to be less specific
> and to store the whole file path.
>
> function! RecordFileOpen()
> let record = "\t(".strftime("%F %T").")\t".expand("%:p")
> redir >> /path/to/log_file
> echo record
> redir END
> endfunction
>
> autocmd! BufReadPre * exe RecordFileOpen()
>
A few things:
1. the 'exe' should be 'call' in the autocmd, as such:
autocmd! BufReadPre * silent call RecordFileOpen()
(The 'silent' is to prevent seeing the log entry on the screen.)
2. With BufReadPre, you get log entries when using Vim's built-in 'help'
But, maybe that's fine for what you're using it for.
3. I'd guess you probably also want BufNewFile (when calling vim on a nonexistent
file):
au! BufReadPre,BufNewFile * sil call RecordFileOpen()
--
Best,
Ben
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment