From bash to vim and back
I recently ran the following command to get my top 5 most used Bash commands:
$ history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5
and here is what came up:
20793 lt
10124 lv
9328 v
8686 j
7243 gst
These are, for the most part – ordinary, everyday commands:
lt
: alias fortree -L 1
v
: alias fornvim
j
: alias forjust
, the fabulous command runnergst
: alias forgit status
What I assume isn’t so obvious is lv
, which stands for
‘last vim’. lv
is an alias for the command
nvim -c "normal '0" -c bd1
, which opens the last opened
file at the last cursor position in a new Neovim buffer.
To break the command down a bit:
nvim
: the Neovim binary-c <cmd>
: Execute<cmd>
after config and first filenormal '0
: The last set cursor position and filebd1
: Delete the first buffer
I use Neovim
alot, and sometimes I quit the editor to run some arbitrary Bash
command. Without having to search for the previously opened file, I
invoke lv
, which gets me back to where I was at.
From bash to vim and back, in a flash.
I'm Liam.
I am compsci undergrad with a minor in mathematics @ mcgill university, rust enjoyer and (neo)vim enthusiast. For fun I enjoy working on open-source projects, reading, and lifting weights.
You can reach out to me via email over at liam@scalzulli.com.