Creating a Vim Quickfix List Programmatically
A Quickfix list in vim is a special buffer that stores a list of file and line locations. Using this list and some commands, you can quickly move through a list of edits.
Normally, a quickfix list is created when you run the
grepcommand, but there are lots of applications where you want may want a list of files and locations. For instance, imagine you create a list of places in your source code that you want to look into later. I have a vim plugin that pulls Github PRs comments into a quickfix list, so I can review comments in my editor and make updates right where I need to.
The key to creating and opening a quickfix list programmatically is the
cexprtakes a newline delimited string in a certain format. The format is defined by
errorformat. You can set your own
:set efm=<your error format>
using special format
%items. Here's a partial list of them:
1 2 3
%f file name (finds a string) %l line number (finds a number) %m error message (finds a string)
:help errorformatfor the full docs.
errorformatcan hold multiple patterns, delimted by commas, so before you set yours, check what you already have on it with
Putting this altogether, lets say you create a file (quickfix.txt) of places you want to inspect like this:
1 2 3
file-a.py:14:this looks interesting file-b.py:26:I have to remember to update this file-c.py:84:This can be deleted when I am done
And you have set your
Then you can open that into a quickfix list like this:
Scale Video and Remove Audio from Videos with ffmpeg-python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import ffmpeg def has_audio(path): probe = ffmpeg.probe(path) return next( (stream for stream in probe["streams"] if stream["codec_type"] == "audio"), None ) path = "" # path to video target_width = 300 vid = ffmpeg.input(path) scaled = vid.filter("scale", target_width, -2) if has_audio(path): trimmed = vid.audio.filter("atrim", start=0, end=0) "Put the scaled video and trimmed audio track back together" joined = ffmpeg.concat(scaled, trimmed, v=1, a=1).node scaled = joined.stream()
Chrome Window Lock
I like to have a window full of dashboards open while I work. I never want a new tab to open there. But often if I give it focus, then click a link somewhere, my new tab will end up there.
This Chrome extension lets you lock a window so it will not create tabs there.