I've noticed that Vim (gVim on Windows 8) unhides hidden files.
By hidden files I don't mean dotfiles; in Windows we don't have dotfiles. It appears that the 'hidden' file attribute on the file is being removed.
Any suggestions/workarounds?
We see this problem on Windows when the writebackup option is enabled and backupcopy is set to no or auto. To fix it, add the following line to .vimrc:
set backupcopy=yes
The writebackup setting instructs Vim to make a backup before overwriting a file, and backupcopy controls how this backup file is created:
"yes" make a copy of the file and overwrite the original one
"no" rename the file and write a new one
"auto" one of the previous, what works best
As we can see, when the value of backupcopy is set to no, Vim will rename the original file that contains the hidden attribute and write a new file in its place without that attribute set (and then delete the backup file afterward unless we enable the backup option). This is faster but can cause problems with file attributes and symlinks.
For more information, read :help backupcopy. We can check the current values of writebackup and backupcopy by running:
:set writebackup? backupcopy?
Related
I'm trying to create a hidden file and for some reason the command touch .fileName doesn't work.
I made sure that my folder and file settings are set to - don't show hidden folders and files.
I'm working with windows10, and Hyper.is terminal.
Windows doesn't care about files beginning with a dot. It just treats them like any old file. If you want to hide a file in Windows you must (also) change that attribute.
attrib +h path-to-file
You can run that from any cmd or PowerShell prompt. It may also work at a bash prompt, though I don't have one in front of me to test it. Using that dual method you can name your file .whatever and then add the above attribute and make it hidden to Windows as well. (Bash should treat the .whatever file as hidden regardless of the Windows attribute.)
Currently it's C:\Windows\System32 which is pretty impractical. I know that you can change the current directory with :cd [directory], but is there any way to change the default save location for new files without having to change directories all the time?
I am not at Windows so I cannot find the exact menu names and such, but if I recall correctly the easiest way to go about it is:
Find your gVim application
Right click it
Choose Properties,
Change the startup location in one of the tabs. The usual place to set it to would be your home directory.
You can change Vim's current working directory with the :cd command.
See
:help :cd
.
If you want Vim to always start in a particular directory, you can
put the :cd command in your ~/_vimrc file.
If you want Vim to use
the parent directory of the file you are editing as its current
working directory, you can put this setting in your ~/_vimrc file:
.
set autochdir
See
:help 'autochdir'
I just did a clean (re)install of Vim (Downloaded from vim.org/download.php, used the gvim73_46.exe installer. Version is 7.3 (patches 1-46)
The only changes to my _vimrc are to set line numbers, lines, columns, and enable syntax.
Everytime I edit a file with vim, save it and close it (:wq), a new _viminfo file is created in that files directory.
Also, the backup *.*~ files and .swp files persist, and arn't cleared upon saving. Running Windows 7 enterprise.
This really clutters everything - and is a pain trying to open a file for which a .swp file exists..
Help?
disable viminfo file:
set viminfo="NONE"
disable swap file:
set noswf
disable backup :
set nobk
set nowb
more details:
:h 'swf'
:h 'bk'
:h 'wb'
:h 'viminfo'
That's strange; the viminfo file should be written in your home directory, nowhere else:
The default name of the viminfo file is "$HOME/.viminfo" for Unix and OS/2,
"s:.viminfo" for Amiga, "$HOME_viminfo" for MS-DOS and Win32. For the last
two, when $HOME is not set, "$VIM_viminfo" is used. When $VIM is also not
set, "c:_viminfo" is used. For OS/2 "$VIM/.viminfo" is used when $HOME is
not set and $VIM is set.
It appears as if your %HOME% variable (or the %HOMEDRIVE%%HOMEPATH%) isn't properly set.
When I open a file with vim or gvim from console on windows that is located in a sub directory (e.g. gvim subdir/file), it creates a new file at subdir\subdir\file saying "subdir\file" [New DIRECTORY] instead of simply opening the existing file at subdir\file.
This happens since I added the following line to my vimrc:
set enc=utf-8
Is there a possibility to open and create files in UTF-8 mode on Windows without this issue?
You may also look at my vimrc file.
Thank you for any help.
Change the order of the autochdir and encoding options in your vimrc. First set the encoding then autochdir
set enc=utf-8
set autochdir
An explanation can be found here
How do I make a file writable from Vim on a Windows machine? I currently manually go find the file in explorer, open it's properties and uncheck readonly. I would like to be able to do this more quickly.
It seems attrib is the Windows shell command to modify file attributes.
See :!attrib /?
:!attrib -R %should remove the Read only property on the file. (It is working here the [RO] flag is modified in my status bar).
You will be prompted to reload the file (if you don't have autoread set) : don't ! and then save with :w!
(Rereading your question I am not sure that the Read only flag is your issue there because :w! should work anyway. )
Maybe I am missing something but :w! works for me.
Use :saveas C:\Users\your_user_name\Desktop\temp.txt and use explorer to copy it to its original location with UAC.