Skip to content

Useful Keybinds

(copy pasting everything from the old site)

The Terminal

I live in a termnal and use vim hence I need to flex and tell everyone about it.

Regardless, here are some useful keybinds which will help you out if you’re a keyboard ninja and don’t use the arrow keys (or even enter and backspace).

CLI Shortcuts/Keybinds

Here’s a list of shortcuts that you can use in the terminal to speed up your work

Shortcut keybindExplanation
Ctrl + aMoves to the START of the line
Ctrl + eMoves to the END of the line (can be used for autocomplete)
Alt + bMoves the cursor 1 word backwards (like ctrl with arrow keys)
Alt + fMoves the cursor 1 word forwards (like ctrl arrow keys))
Ctrl + pLast command (like the up arrow )
Ctrl + nNext command (like down arrow)
Ctrl + wDelete the word (like ctrl/alt + backspace)
Alt + dDelete word (ahead)
Ctrl + rReverse search (searching through command history)
Ctrl + kDelete everything till end of the line
Ctrl + uDelete everything to the start of the line
Ctrl + x eOpens command in your default text editor (vi/nano etc)

Ctrl + x e opens up your default editor (vi/nano) through which you can edit the command you are typing. This is really useful when you have a long command, and you don’t want to keep navigating around the terminal with the arrow keys etc.

Easy Navigation

Navigating through the filesystem on Linux or any operating system is annoying and tiring- but not anymore. The zsh alias below will allow you to fuzzyfind through everything in the current directory, AND it will cd into the directory of item you have selected !!

AND it will ignore the node_modules folder and all dotfiles .*.

Terminal window
alias dc='noglob cd "$(dirname "$(find "$PWD" -type d \( -name ".*" \) -prune -o -type f -print | grep -v "node_modules" | fzf)")"'

Add this to your ~/.zshrc and watch the magic happen. I recommend that you change the alias dc to something else that you’ll remember. I named it dc since its the opposite of cd.

Another similar command is

Terminal window
cd $(dirname $(echo $PWD/$(fzf)))
# echo $PWD prints the current directory
# fzf gets the relative path of the file you want
# and dirname removes the file name so it navigates
# to the directory of that file

which does the same thing but doesn’t ignore any folders.

Watch the video below to see it in action. (media not working. will fix later)

Vim Navigation Aliases

Sometimes you wanna open a file in vim/neovim, but you don’t want to waste your time looking around with cd and so on. A simple fix for this is using fzf in the neovim/vim command to open a file

terminal
nvim $(fzf)

It’s that simple!

You can add aliases for this to save some keystrokes. Below is an alias I use since I don’t want it to clash with nvim or vim

zshrc
alias ovim='/snap/bin/nvim $(fzf)'
# replace the location of snap/bin/nvim with the location of your neovim binary or just use the command itself
alias ovim='nvim $(fzf)'

Now you can open up a file in vim without going through the pain of navigating the filesystem with cd.

tests