After the last long one, today is a short, but useful tip. There is a
we are in command mode and that’s the relative path of the currently edited
file. We can add some flags to it to make it more useful. Let’s see through some
We can use the file path to call external problems like
We can use tab completion to edit/create a new test file easily with
and after that we only have to edit the path for example from
Doing that would be a pain all the time, there are filename modifiers. Here is
short list where the edited file is
%:p: Absolute path to the file.
%:h: Head of the filename, like the parent directory (
%:t: Tail of the filename. The actual filename. (
%:r: Root of the filename, basically removed the last extension. This is useful when we want to save out file with a new extension. (
%:e: Opposite of
%:r, it’s the last extension. (
substitution. For example:
%:gs?pattern?substitution?: Same as
%:s?..., but all occurrences.
We can chain them together (where it makes sense). For example if we have a temporary file and we want to save when we are done with it, we can simply manipulate the value to save to the right place.
For this series, I have a
blind-draft/aov21/_dayXX.md for each day. That way
if I don’t finish it in time, it will not be published accidentally. So when I’m
done with a file, I can save it to the right place with with:
Because it’s a command, it can be in a
map, and it’s in the command history
and I have to change nothing because it preserves the day number.
2021-12-18 00:00 +0000