Vim

Written on January 4, 2023 by Fiqry choerudinJanuary 4, 2023
4 min read
719 words

It's been 3 months since I started using Vim as my secondary IDE. I began learning how to use Vim because I saw my friend using it as his daily IDE and I thought it was so cool. At the first time I used Vim, I wanted to give up because it was so hard 😂. There were so many key bindings I had to remember and it was hard to configure. After a month of using it, I started enjoying Vim as my IDE because it was getting easier to use and simpler to configure. I use tmux, fish shell, and Neovim as my primary setup for my terminal, and I also started creating aliases for faster workflows.

Heres how i configure vim for my workflows , i use craftzdog dotfile and started modified for my personal use, here's my config :

Ingredients

  • vim (NeoVim)
  • tmux
  • fish

Tmux action key

# action key
unbind C-b
set-option -g prefix C-t
set-option -g repeat-time 0
set-option -g focus-events on

#### Key bindings

set-window-option -g mode-keys vi

#bind t send-key C-t
# Reload settings
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Open current directory
bind o run-shell "open #{pane_current_path}"
bind -r e kill-pane -a

# vim-like pane switching
bind -r k select-pane -U
bind -r j select-pane -D
bind -r h select-pane -L
bind -r l select-pane -R

# Moving window
bind-key -n C-S-Left swap-window -t -1 \; previous-window
bind-key -n C-S-Right swap-window -t +1 \; next-window

# Resizing pane
bind -r C-k resize-pane -U 5
bind -r C-j resize-pane -D 5
bind -r C-h resize-pane -L 5
bind -r C-l resize-pane -R 5

Shell setup (macOS & Linux)

Neovim setup

Requires Neovim (>= 0.8)

Aliases config :

# aliases
alias ls "ls -p -G"
alias la "ls -A"
alias ll "ls -l"
alias lla "ll -A"
alias . "nvim ."

# git aliases
alias g git
alias ga "git add ."
alias gcm "git commit -m"
alias gpo "git push origin"
alias gco "git checkout"
alias clone "git clone"

# go alias
alias gr "go run"
alias gb "go build"

# yarn aliases
alias yd "yarn run dev"
alias yi "yarn install"
alias yad "yarn add"

# pnpm alias
alias pi "pnpm install"
alias pd "pnpm run dev"
alias ps "pnpm run start"
alias pt "pnpm run test"

# vm alias
alias vm "ssh vm"

# create react app
alias cra "npx create-next-app --example https://github.com/fiqryq/next-boilerplate"

alias ide "tmux split-window -v -p 30"