Now, I’m full time using VIM and it’s not bad at all

ervinismu
pengenpaham
Published in
5 min readMar 24, 2024

--

Photo by Tran Mau Tri Tam ✪ on Unsplash

A few months ago, jump into VIM from my prev code editor. In this article i write a quick recaps what i learn and my setup, hope it will help you if you want to do same things.

For little background, my daily working is a mostly working as a back-end developer and write some Go and Ruby stuffs.

Table Of Contents

  • Reason
  • Configuration
  • My Most Used Command
  • Some UI screenshots
  • Lesson and Learn
  • Conclusion

Reason

Before i jump into VIM, rethinking my reason “Why i need to jump into it?” and i realized this reasons (so far) :

1) Cool

VIM community is HUGEEE… old school code editor, but still relevant until now, make me not scary when jump into it. I am not alone, finally i am not alone (lol)

2) Bug in prev code editor

Before it, i found issue in my prev code editor and struggle for solve this issue in a few weeks (lol).

3) Stay Minimalist

I want to configure with minimal as i need and learn something else, got bored with my current dev setup.

4) Daily Work

My daily work is mostly writing Go and Ruby code, and VIM is more than enough for working with it.

5) Working Device

Recently i moved from Macbook to Thinkpad x220, for daily driver device, which is i need something simple but good.

Configuration

After using VIM with default config, i decided to configure my .vimrc, but with minimal config as i can, my one of goal is not bloated my lovely VIM with Plugin/Config and stay minimalist.

1) Basic Config And Plugin

My .vimrc is looks like this. You can see in my Github in this link!

" ==================
" >> Basic Config <<
" ==================

" Turn on auto indent when paste, to avoid unexpected effect
set paste

" Show the filename in the window titlebar
set title

" enable hybrid line number
set number relativenumber

" Show “invisible” characters
set lcs=tab:▸\ ,trail:·,nbsp:_
set list

" Highlight current line horizontally
set cursorline

" Highlight cursor line vertically
set cursorcolumn

" highlight search
set hlsearch

" Highlight dynamically as pattern is typed
set incsearch

" Enable mouse
set mouse=a

" Enable syntax highlight
syntax on

" option will copy your current indentation when creating a new line
set copyindent
set softtabstop=0
set shiftwidth=4
set tabstop=4
set expandtab

" Set encoding
set encoding=utf8

" airline font
let g:airline_powerline_fonts = 1

" vim-go config
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'


" =====================
" >> NERDTree Config <<
" =====================

" Open FZF Prompt using Ctrl + p
nnoremap <silent> <expr> <c-p> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":FZF \<cr>"

" Enable tab split when search file using FZF
let g:fzf_action = { 'enter': 'tab split' }

" Toggle nerdtree nav using Ctrl + a
nnoremap <C-a> :NERDTreeToggle<CR>

" CATPUCCIN
" This is only necessary if you use "set termguicolors".
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

" fixes glitch? in colors when using vim with tmux
set background=dark
set t_Co=256
set termguicolors
let g:lightline = {'colorscheme': 'catppuccin_mocha'}
let g:airline_theme = 'catppuccin_mocha'

" ========================
" >> Plugins (vim-plug) <<
" ========================

call plug#begin()
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'preservim/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'ryanoasis/vim-devicons'
Plug 'catppuccin/vim', { 'as': 'catppuccin' }
call plug#end()

" NOTE :
" vim-devicons : may be broken if you dont set Droidsans font. reference -> https://github.com/ryanoasis/vim-devicons/wiki/Installation#set-font
" if you dont use GuiVim, change your terminal font using droidSansMono or hackNerd.

As you can see in this code block, this is all my plugins goes on. I used VimPlug for install plugin.

call plug#begin()
" .....
call plug#end()

My plugin is installed using using vim-plug, little summary about my installed plugin here :

  • FZF : command file fuzzy finder, we can combine it using NERDTree for searching file, it’s really good!
  • NERDTree : file system explorer, usefull when we open folder using vim, for easy navigation and file explorer.
  • Vim-Airline : status bar at the bottom opened file.
  • Vim-Go : improve Golang development environment, it will enabled feature such as go-to definition.
  • Vim-Devdocs : file type icons for VIM, it’s good when combined with NERDTree when showing file navigation.
  • Catppuccin : Soothing pastel theme for Vim.

Some UI screenshots

When open project folder with normal mode :

vim normal mode with opened NERDTree

When search file in current opened folder :

vim search file

When search text in current opened folder :

vim searching text

My Most Used Command

My most used comment i use for daily working :

1) Searching text in opened file

Press Esc and type /, for example if we want to search word hello, type /hello and ready to go. If found multiple hello word press Enter and press n for jump between searched word. I prefer use Exact match for searching.

2) Searching text in opened folder

Press Esc and type :Ag, for text searching. It will show a prompt and you can typed text you want to searched.

3) Searching file in current opened folder

In my .vimrc, i setup FZF using shortcut Ctrl+p for showing FZF prompt. Type Ctrl + p and prompt will showed.

4) Golang go-to definition

type Ctrl+] for go-to definition and press Ctrl+t to jump into prev. It is use full when working with Golang codebase.

5) Golang error check

type :GoErrCheck for check if any error will showed up in .go file

6) Replace word with other word

Press Esc and type :%s/oldWord/newWord/%g , for example when you want to replace text hello with world you can do this :%s/hello/world/%g and press Enter.

Lesson and Learn

My lesson learn after full-time using VIM for daily working in a few months.

1) Remember something (keyboard shortcut)

When we use VIM, we need to remember command/keyboard shortcut, because mostly we work using keyboard and not using mouse.

2) Manage conflict keyboard shortcut

Manage keyboard shortcut is tricky, in my first week using Vim, my keyboard shortcut is conflict between NerdTREE and Vim-Go, for example :

  • Ctrl+t : open and close NerdTreeToggle
  • Ctrl-t : Vim-Go for go-to definition

3) Don’t Scary

Seriously, don’t scary..

  • don’t scary to move on
  • don’t scary to learn something new
  • don’t scary to do something when other people scary with it (especially scary can’t exit their VIM)

If you have a good reasons to do it, do it! now!

Conclusion

VIM is a good editor, worth it to give it a try. If you any recommendation config or want to share your opinion, let’s discuss in comment section.

Thank you for reading! and peace 🍉

--

--

ervinismu
pengenpaham

full time writer, part time software engineer, long life learner