BufReadPost getfsize and scp

Visto 21 veces
Saltar al primer mensaje no leído

David

no leída,
3 may 2011, 3:50:053/5/11
a vim_use
I am using an autocommand to disable syntax highlighting for large
files.

I do this with:

au BufReadPost * if getfsize(bufname("%")) > 512*1024 | set syntax= |
endif

This will disable syntax for files bigger than 512kB.
However this is not working if I access files via scp://...

I assume vim thinks the file has 0Bytes and therefore does not disable
the hightlighting.
I tried some other events (e.g. BufWinEnter), but they didn't work
either for this.

Has anyone experience with events and scp or a good tip how to solve
this?

It would also help if there is a way to let Vim print out every event
it throws.

Ben Schmidt

no leída,
3 may 2011, 4:39:573/5/11
a vim...@googlegroups.com,David

I don't know if it deals with this situation, but Dr. Chip's LargeFile plugin
disables various things to make editing large files more bearable, and since he
wrote netrw, too, maybe he's got some appropriate magic in place. Worth checking
out, I think. You should easily find it if you Google.

Cheers,

Ben.


David

no leída,
3 may 2011, 4:57:243/5/11
a vim_use
On 3 Mai, 10:39, Ben Schmidt <mail_ben_schm...@yahoo.com.au> wrote:
> I don't know if it deals with this situation, but Dr. Chip's LargeFile plugin
> disables various things to make editing large files more bearable, and since he
> wrote netrw, too, maybe he's got some appropriate magic in place.

I tried the important line of the plugin to test, but it did not work.

But I think it might be a good idea to look a bit into netrw.
Thanks for mentioning it.

David

Charles Campbell

no leída,
3 may 2011, 10:48:193/5/11
a vim...@googlegroups.com

Netrw attempts to minimize the number of times that a password may be
needed, so it doesn't attempt to find out what the file size is before
getting the file via scp (or ftp).

LargeFile, like DL's example, uses getfsize() to do its automatic
large-file determination.

However, it does have a "force-it" option: try using :Large!
(instead of :Large).

Regards,
Chip Campbell

David

no leída,
4 may 2011, 7:18:564/5/11
a vim_use
On 3 Mai, 16:48, Charles Campbell <Charles.E.Campb...@nasa.gov> wrote:
> Netrw attempts to minimize the number of times that a password may be
> needed, so it doesn't attempt to find out what the file size is before
> getting the file via scp (or ftp).

So it does not throw any useful events for my case, does it?


> LargeFile, like DL's example, uses getfsize() to do its automatic
> large-file determination.
> However, it does have a "force-it" option:  try using   :Large!  
> (instead of :Large).

This works only after I have loaded the file then, correct?
It does indeed speed up things quite a lot, but I'd prefer a totally
automatic solution for this.

David


Charles Campbell

no leída,
17 may 2011, 16:50:4417/5/11
a vim...@googlegroups.com,David
Please try v5h of LargeFile.vim (available at
http://mysite.verizon.net/astronaut/vim/index.html#LARGEFILE).

I haven't tested it using scp/ftp myself, but I've put some code in it
that should:

* uses getfsize(); if the file is large, s:LargeFile() will do its
usual thing (turning off syntax, etc)
* if getfsize() returned -2, then s:LargeFile() will do its usual thing
* if getfsize() returned -1, as generally happens with ftp://.... and
scp://... , then after the file has loaded, it will check if
line2byte(line("$")) is large, and if so, s:LargeFile() will be called
with force to treat it as a large file.

Regards,
Chip Campbell

David

no leída,
18 may 2011, 2:04:2618/5/11
a vim_use
On 17 Mai, 22:50, Charles Campbell <Charles.E.Campb...@nasa.gov>
wrote:
> Please try v5h of LargeFile.vim (available at  http://mysite.verizon.net/astronaut/vim/index.html#LARGEFILE).

I tried it and so far it does not do the job.

In this autocommand:
au BufReadPost *
\ if &ch < 2 && line2byte(line("$")) >= g:LargeFile*1024*1024
\| if exists("b:LargeFile_mode") && b:LargeFile_mode == 0|call
LargeFile(1,expand(""))|endif
\| echomsg "***note*** handling a large file"
\| endif

The if exists("b:LargeFile_mode") does not work for me. If I cut the
whole second if it does.
But it does not work even then if I open a file using tabedit scp://...,
because &ch seems be 2.

David

Charles Campbell

no leída,
18 may 2011, 9:48:0318/5/11
a vim...@googlegroups.com
David wrote:
> On 17 Mai, 22:50, Charles Campbell<Charles.E.Campb...@nasa.gov>
> wrote:
>
>> Please try v5h of LargeFile.vim (available at http://mysite.verizon.net/astronaut/vim/index.html#LARGEFILE).
>>
> I tried it and so far it does not do the job.
>
> In this autocommand:
> au BufReadPost *
> \ if&ch< 2&& line2byte(line("$"))>= g:LargeFile*1024*1024
> \| if exists("b:LargeFile_mode")&& b:LargeFile_mode == 0|call

> LargeFile(1,expand(""))|endif
> \| echomsg "***note*** handling a large file"
> \| endif
>
> The if exists("b:LargeFile_mode") does not work for me. If I cut the
> whole second if it does.
> But it does not work even then if I open a file using tabedit scp://...,
> because&ch seems be 2.
>
I think v24i will now implement automatic large file handling via
scp/ftp. Please check my website again.

Regards,
Chip Campbell

David

no leída,
30 may 2011, 6:25:4030/5/11
a vim_use
On 18 Mai, 15:48, Charles Campbell <Charles.E.Campb...@nasa.gov>
wrote:
> I think v24i will now implement automatic large file handling via
> scp/ftp.  Please check my website again.

It is v5i, isn't it?
But yes, it is working. Thank you very much!

Another remark: there are two lines with [[[1 in them which cause the
files to be named "LargeFile.vim [[[1" and "LargeFile.txt
[[[1".
is this an error on my side or just a folding typo?

David

Charles Campbell

no leída,
31 may 2011, 9:09:3231/5/11
a vim...@googlegroups.com

Are you using vim 7.0? You really should update; vim is up to 7.3 now
(with 206 patches available).

Regards,
Chip Campbell

David

no leída,
31 may 2011, 9:16:2531/5/11
a vim_use
On 31 Mai, 15:09, Charles Campbell <Charles.E.Campb...@nasa.gov>
wrote:
> Are you using vim 7.0?  You really should update; vim is up to 7.3 now
> (with 206 patches available).

Yes I do. I guess in that case it is not an error at all.
I would really like to update, but I don't have root access on my work
computers.

Thanks!

David

Michael Henry

no leída,
3 jun 2011, 6:57:293/6/11
a vim...@googlegroups.com,David
On 05/31/2011 09:16 AM, David wrote:
> I would really like to update, but I don't have root access on my work
> computers.

You can compile vim as an unprivileged user and install it in
your home directory. Tony Mechelynck has a nice tutorial on
compiling Vim in general:
http://users.skynet.be/antoine.mechelynck/vim/compunix.htm

You'll want to modify that a bit to change the "prefix" for the
installation to be within your home directory. Vim's
documentation has more explanation:
http://vimdoc.sourceforge.net/htmldoc/usr_90.html

See the section on "SELECTING FEATURES" in the above link. The
``--prefix`` option allows you to target your home directory
instead of /usr/local as the expected installation location.

If you get stuck, I'm sure the list will be able to help you get
past any compilation issues.

Michael Henry

John Little

no leída,
5 jun 2011, 4:08:105/6/11
a vim_use
> On 05/31/2011 09:16 AM, David wrote:
>
> > I would really like to update, but I don't have root access on my work
> > computers.

On Jun 3, 10:57 pm, Michael Henry <v...@drmikehenry.com> replied:
> You can compile vim as an unprivileged user and install it in
> your home directory.

I've been forced into this on Unix and Linux systems, by overly
conservative admins. For vim itself, it's quite straightforward.

It gets tricky if you want features (say, gvim) that require libraries
the system hasn't got; I've been forced to compile and build those
first, and their dependencies, then tell the vim build where to find
the headers and libraries. Can anyone give some pointers for this?

Regards, John

Ivan Krasilnikov

no leída,
5 jun 2011, 18:54:135/6/11
a vim...@googlegroups.com
On Sun, Jun 5, 2011 at 12:08, John Little <john.b...@gmail.com> wrote:
> I've been forced into this on Unix and Linux systems, by overly
> conservative admins.  For vim itself, it's quite straightforward.
>
> It gets tricky if you want features (say, gvim) that require libraries
> the system hasn't got; I've been forced to compile and build those
> first, and their dependencies, then tell the vim build where to find
> the headers and libraries.  Can anyone give some pointers for this?

Sounds just like what I have at my work. I build and install into my
home directory my own gvim, with gtk and x11 libraries built from
scratch. Here's my build script
https://github.com/infnty/configs/raw/master/bsd/survival-kit.py, you
may find it useful if you speak python.

There's a lot of useful information about building these libraries and
their dependencies on LFS project site -
http://www.linuxfromscratch.org/blfs/view/svn/index.html.

Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos