Hot answers tagged

6

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. command! \ -count=0 -nargs=? \ -complete=file \ DumpRegister \ echo 'call writefile(getreg("<count>", 1,...


4

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 ...


3

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 endif See :h let-& and :h expr-option for details.


2

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 ...


2

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 ...


2

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 ...


2

To redirect to a file, you need to use > :redir! > /tmp/3 See :help :redir for more details. To use this to write the contents of register "0 into /tmp/3: :redir! > /tmp/3 :echo @0 :redir END


2

One way is to populate the quickfix list with matches then use :cfdo to execute :bdelete :vimgrep /pat/ ## :cfdo bdelete 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: :h :vimgrep :h :grep :h :cfdo :h :...


1

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 && ...


1

Put this in your .vimrc: set path+=** This will also search in all subdirectories. Then use the :find command. Start writing a part of the filename, for example... :find io ...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.


Only top voted, non community-wiki answers of a minimum length are eligible