Have you tried to obtain the register as a list instead? See :h getreg()
:call writefile(getreg('0', 1, 1), ....)
PS: temporary filenames are best obtained with tempname()
Now, let's put this into a command. Sorry, I'll dot some dirty things.
\ -count=0 -nargs=?
\ echo 'call writefile(getreg("<count>", 1,...
Which inotify events are fired depends on how Vim writes the file. This is
controlled by multiple options.
In a typical setup it works like this. Assume Vim wants to write the file e.txt
Vim moves the file e.txt to e.txt~
Vim creates a new file e.txt and writes its content
In this case the event MOVE_SELF would be fired. As tools like inotifywait
(with -m ...
You can use set ff? to check current file format 'interactively'.
If you need to check it in a vimscript, you can use
if &ff ==# 'unix'
"do smth if file format is unix
See :h let-& and :h expr-option for details.
Don’t do the 'path' trick. The 'path' option affects many of vim’s best navigational techniques.
Instead (and I only learned about this recently—see :help 'wildmenu'), when you’re dealing with directories:
use Down to “drill down” into the subdirectory and start completing filenames below
use Up to “move up” into the parent directory and complete filenames ...
Here are three options depending on what you are trying to achieve:
If you specifically want the output of grep, then you can just use :grep/:vimgrep from within vim. This will populate the quickfix window with a list of files which you can browse and press Enter to open.
If you have a different command that generates your list of files, but it is ...
Unlike netrw, there are Vim file managers who follow a different paradigm: simply fill in some lines and present'em "as if it's a file list".
The most well-known "buffer-like file manager" is probably vim-dirvish. As a shameless plug, I also wrote one of my own called vim-drvo.
So you can create a buffer containing random file names, type ...
One way is to populate the quickfix list with matches then use :cfdo to execute :bdelete
:vimgrep /pat/ ##
Even though the files are closed the files are still in the argument-list. Remove them via :argdelete with % to represent the current file
:vimgrep /pat/ ##
:cfdo bdelete | argdelete %
For more help see:
Vim doesn't really include a mechanism for this; but it does include "timers" for running functions in the background.
With this, we can add a timer to check the modification time of a file every n seconds and issue an error if this changes. For example:
fun s:check(file, last) abort
let mtime = getftime(a:file)
if a:last isnot 0 && ...
Put this in your .vimrc:
This will also search in all subdirectories.
Then use the :find command. Start writing a part of the filename, for example...
...and then when you press Tab, it will autocomplete or offer possible matches from which you can choose. It will find io.py even if it's in a subdirectory.