- Published on
The terminal based workflow
- Authors
- Name
- ディーン・タリサイ
- @prjctimg
The text editor
My first ever text editor was vscode
, a popular and "sensible at first sight" choice for beginners and pros alike. It was very easy to get up and running plus it was easy to click around for things (heavy trackpad user back then). The real pain started when I downgraded to dual core machine, coding became frustrating because things took ages to do now.
The latency between keystrokes was unbearable, the editor was consuming more resources than I could spare. Even with just 2 or 3 extensions installed the editor would occasionally hit an ERR_OUT_OF_MEMORY
and exit gracefully. By gracefully, I mean the "BSOD comes popping out of nowhere" kind. Running a development server for a React project was impossible, the UI would be choked with keystrokes being registered almost 5 seconds after being pressed.
The motivation for trying out terminal based editors was because of the limited hardware specs I had at that time. Even after I had upgraded, and could now afford to run multiple instances of vscode
without any lag, I had become used to Vim motions, there was possibly no easier way to manipulate text. It was fast and made it easy to fly around a code base.
I am no Vim configuration guru so I use LazyVim as a starting point, probably the most stable Neovim distro out there right now (bold claim, I know). The ability to code how your editor behaves exposes a whole new dimension of possibilities.
Extending the keymaps
The default LazyVim keymaps are great and easy to memorize but most of them don't work in, for example, insert
mode. I had several motivations on how I wanted to access my frequently used views.
The shortcuts were supposed to meet these requirements:
- Allow me to access views like file and emoji pickers
- Make it unnecessary to exit modes before I can access a feature
- Make navigation as easy as possible
NOTE
The tricky part was in deciding which key modifier to use, I eventually settled for Alt
for ergonomic reasons, though this meant that I had to remove my shell keybindings which also use the Alt
key as the modifier.
I also wanted to bring some of the vscode
functionalities I liked such as selecting text by pressing Shift
+ arrow keys. Exiting to visual mode manually just sounded to tedious to repeat manually. For copying (yanking) and pasting (putting) text I wanted to have a view of the yanking history to pick the text I wanted with ease.
This meant that I had to unbind the default Ctrl + C
and Ctrl + V
actions I previously used.
autocmds
and init.lua
Reacting to editor events with Auto commands are routines executed when watched events happen in the editor, this can be opening or closing a buffer, moving a cursor or opening/closing nvim
itself.
Being lazy, there's so many events I'd really appreciate if my editor reacted for me instead. For example instead of having to manually press Ctrl + K
to get an LSP symbol's help, the help window should trigger automatically after a delay.
Other tweaks I wanted to have are
- Change the theme for based on the time of day
- Start a timer session automatically when I open
nvim
- to give me a sensse of urgency - Daily stoic reading when I enter neovim for the first time
- Pick emojis through
nvim
since the system emoji picker doesn't trigger in the terminal (somehow) - Toggle between light and dark themesqq
The final result was a satisfying custom configuration that allowed me to do just what I wanted.
You can find my configuration here for inspiration.
1`