Re: Noswap and Nobackup when editing python on a specific device (mounted) on Linux

2018-11-22 Thread Christian Brabandt


On Fr, 23 Nov 2018, Tony Mechelynck wrote:

> On Thu, Nov 22, 2018 at 9:21 PM Gary Johnson  wrote:
> >
> > On 2018-11-22, tu...@posteo.de wrote:
> > > Hi,
> > >
> > > from time to time I have to edit a python file, which
> > > is stored on the 2M flash memory on a microcontroller
> > > board.
> > >
> > > To avoid unneccassary write cycles to the flash (flash wear out)
> > > I want to disable backup and swapfile in such a case.
> > >
> > > And to ensure both are switched off even if I have forgotten
> > > to do so, vim should do that automatically.
> > >
> > > I am working under Linux.
> > >
> > > The mountpoint for the flash (the microcontroller represents
> > > itsself as "USBstick" with 2M memory space...) is
> > > /home/user/flash and I am always editing python code.
> [...]
> 
> 'backup' and 'writebackup' are global options, so disabling them for
> one file disables them for every file. If that's what you want, you
> can set them off in your vimrc. However, ":set nobackup writebackup"
> is supposed to leave nothing hanging around once the write has
> succeeded.

You could set the backupskip option and add the directory of your flash 
directory to skip creating backup files.

> 
> For 'swapfile', which is buffer-local, it is easier. I suggest the
> following (untested):
> 
> autocmd BufNewFile,BufReadPre /home/user/flash/**/* setlocal noswapfile

I would have suggested that one, but since it appears to not be working 
at all, I would simply set the 'directory' option and store all 
swapfiles in a common directory.

Best,
Christian
-- 
Impotenz ist die beste Form der Empfängnisverhütung.
-- Zarko Petan

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Noswap and Nobackup when editing python on a specific device (mounted) on Linux

2018-11-22 Thread Gary Johnson
On 2018-11-23, Tony Mechelynck wrote:
> On Thu, Nov 22, 2018 at 9:21 PM Gary Johnson  wrote:
> >
> > On 2018-11-22, tu...@posteo.de wrote:
> > > Hi,
> > >
> > > from time to time I have to edit a python file, which
> > > is stored on the 2M flash memory on a microcontroller
> > > board.
> > >
> > > To avoid unneccassary write cycles to the flash (flash wear out)
> > > I want to disable backup and swapfile in such a case.
> > >
> > > And to ensure both are switched off even if I have forgotten
> > > to do so, vim should do that automatically.
> > >
> > > I am working under Linux.
> > >
> > > The mountpoint for the flash (the microcontroller represents
> > > itsself as "USBstick" with 2M memory space...) is
> > > /home/user/flash and I am always editing python code.
> [...]
> 
> 'backup' and 'writebackup' are global options, so disabling them for
> one file disables them for every file. If that's what you want, you
> can set them off in your vimrc. However, ":set nobackup writebackup"
> is supposed to leave nothing hanging around once the write has
> succeeded.
> 
> For 'swapfile', which is buffer-local, it is easier. I suggest the
> following (untested):
> 
> autocmd BufNewFile,BufReadPre /home/user/flash/**/* setlocal noswapfile

I tried part of that,

au BufReadPre *.py setlocal noswapfile

with the same results as "au FileType python", that is, I didn't see
a swapfile in the directory, but the modification time of the
directory changed, indicating that the swap file had been created,
then deleted.

Regards,
Gary

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Noswap and Nobackup when editing python on a specific device (mounted) on Linux

2018-11-22 Thread Tony Mechelynck
On Thu, Nov 22, 2018 at 9:21 PM Gary Johnson  wrote:
>
> On 2018-11-22, tu...@posteo.de wrote:
> > Hi,
> >
> > from time to time I have to edit a python file, which
> > is stored on the 2M flash memory on a microcontroller
> > board.
> >
> > To avoid unneccassary write cycles to the flash (flash wear out)
> > I want to disable backup and swapfile in such a case.
> >
> > And to ensure both are switched off even if I have forgotten
> > to do so, vim should do that automatically.
> >
> > I am working under Linux.
> >
> > The mountpoint for the flash (the microcontroller represents
> > itsself as "USBstick" with 2M memory space...) is
> > /home/user/flash and I am always editing python code.
[...]

'backup' and 'writebackup' are global options, so disabling them for
one file disables them for every file. If that's what you want, you
can set them off in your vimrc. However, ":set nobackup writebackup"
is supposed to leave nothing hanging around once the write has
succeeded.

For 'swapfile', which is buffer-local, it is easier. I suggest the
following (untested):

autocmd BufNewFile,BufReadPre /home/user/flash/**/* setlocal noswapfile

Best regards,
Tony.

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Noswap and Nobackup when editing python on a specific device (mounted) on Linux

2018-11-22 Thread Gary Johnson
On 2018-11-22, tu...@posteo.de wrote:
> Hi,
> 
> from time to time I have to edit a python file, which
> is stored on the 2M flash memory on a microcontroller
> board.
> 
> To avoid unneccassary write cycles to the flash (flash wear out)
> I want to disable backup and swapfile in such a case.
> 
> And to ensure both are switched off even if I have forgotten
> to do so, vim should do that automatically.
> 
> I am working under Linux.
> 
> The mountpoint for the flash (the microcontroller represents
> itsself as "USBstick" with 2M memory space...) is
> /home/user/flash and I am always editing python code.
> 
> I tried
> autocmd FileType python setlocal nobackup
> autocmd FileType python setlocal noswapfile
> as a first test...but it fails (supposedly a layer eight failure...)
> 
> How can I acchieve this trick?
 
It appears that Vim creates the swap file before determining the
file type.  I tried your autocommand for setting noswapfile and no
swap file appeared in the directory, so in that sense it worked for
me, but I could see by the directory's modification time that it had
been changed, so presumably the swap file was initially created then
deleted when the autocommand triggered.  The following seemed to
work, though.

set noswapfile
au FileType * if  != 'python' | setlocal swapfile | endif

HTH,
Gary

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Noswap and Nobackup when editing python on a specific device (mounted) on Linux

2018-11-22 Thread arocker
> 2018-11-22 19:16 GMT+01:00, tu...@posteo.de :
>> To avoid unneccassary write cycles to the flash (flash wear out)
>> I want to disable backup and swapfile in such a case.

Is it technically impossible to copy the file to a work directory, edit
it, and write back the edited result?

That might even make it possible to maintain the source code with an RCS,
if you make the directory permanent.

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Noswap and Nobackup when editing python on a specific device (mounted) on Linux

2018-11-22 Thread tuxic
On 11/22 07:41, Kit wrote:
> 2018-11-22 19:16 GMT+01:00, tu...@posteo.de :
> > To avoid unneccassary write cycles to the flash (flash wear out)
> > I want to disable backup and swapfile in such a case.
> > How can I acchieve this trick?
> >
> > Meino
> 
> https://medium.com/@Aenon/vim-swap-backup-undo-git-2bf353caa02f
> 
> $ mkdir ~/tmp
> 
> ~/.vimrc:
> set backupdir=~/tmp//
> set directory=~/tmp//
> set undodir=~/tmp//
> -- 
> Kit
> 
> -- 
> -- 
> 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 because you are subscribed to the Google Groups 
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to vim_use+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 

That does something completly different.
I want to disable the creation of backup and swapfiles.
See my initial post.

Cheers!
Meino

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Noswap and Nobackup when editing python on a specific device (mounted) on Linux

2018-11-22 Thread Kit
2018-11-22 19:16 GMT+01:00, tu...@posteo.de :
> To avoid unneccassary write cycles to the flash (flash wear out)
> I want to disable backup and swapfile in such a case.
> How can I acchieve this trick?
>
> Meino

https://medium.com/@Aenon/vim-swap-backup-undo-git-2bf353caa02f

$ mkdir ~/tmp

~/.vimrc:
set backupdir=~/tmp//
set directory=~/tmp//
set undodir=~/tmp//
-- 
Kit

-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Noswap and Nobackup when editing python on a specific device (mounted) on Linux

2018-11-22 Thread tuxic
Hi,

from time to time I have to edit a python file, which
is stored on the 2M flash memory on a microcontroller
board.

To avoid unneccassary write cycles to the flash (flash wear out)
I want to disable backup and swapfile in such a case.

And to ensure both are switched off even if I have forgotten
to do so, vim should do that automatically.

I am working under Linux.

The mountpoint for the flash (the microcontroller represents
itsself as "USBstick" with 2M memory space...) is
/home/user/flash and I am always editing python code.

I tried
autocmd FileType python setlocal nobackup
autocmd FileType python setlocal noswapfile
as a first test...but it fails (supposedly a layer eight failure...)

How can I acchieve this trick?

Thanks a lot for any help in advance!
Cheers!
Meino


-- 
-- 
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 because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.