Home / Posts / From bash to vim and back View Raw
25/02 — 2022
16.38 cm   1.4 min

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:

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 file
  • normal '0: The last set cursor position and file
  • bd1: 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'm currently a software engineer intern at 1Password on the Filling and Saving team, where I primarily work on the browser extension and related infrastructure.

I also study computer science at McGill University.

I like developer tooling, distributed systems, performance engineering and compiler design.

You can reach out to me via email at liam@scalzulli.com.

Home / Posts / From bash to vim and back View Raw