-
Sane Vim defaults (from Neovim)
Vim comes with a set of often outdated and counter-intuitive defaults. Vim has been around for around 30 years, and it only makes sense that many defaults did not age well.
Neovim addresses this issue by being shipped with many default options tweaked for modern editing experience. If you can’t or don’t want to use Neovim - I highly recommend setting some these defaults in your
.vimrc
:if !has('nvim') set nocompatible syntax on set autoindent set autoread set backspace=indent,eol,start set belloff=all set complete-=i set display=lastline set formatoptions=tcqj set history=10000 set incsearch set laststatus=2 set ruler set sessionoptions-=options set showcmd set sidescroll=1 set smarttab set ttimeoutlen=50 set ttyfast set viminfo+=! set wildmenu endif
The defaults above enable some of the nicer editor features, like
autoindent
(respecting existing indentation),incsearch
(search as you type), orwildmenu
(enhanced command-line completion). The defaults also smooth out some historical artifacts, like unintuitive backspace behavior. Keep in mind, this breaks compatibility with some older Vim versions (but it’s unlikely to be a problem for most if not all users). -
Status bar color in Vim terminal mode
If you’re using a custom color scheme (why wouldn’t you?) in conjunction with a terminal mode in Vim (again, why wouldn’t you?), you may have noticed that the terminal status bar has no respect for your color scheme.
Run
:term
, and you’ll be greeted to the default status bar:Since terminal mode is still in beta in Vim 8.1, we have to manually set the highlighting groups. It’ll require a bit of digging.
Navigate to the directory containing your current color scheme. Depending on the plugin manager, the color schemes are located in different places. On Linux, default color schemes often live in
/usr/share/vim/vimcurrent/colors
. In this example, I’m using PaperColor scheme, and I have it installed using vim-plug in~/.vim/plugged/papercolor-theme
, andcolors/PaperColor.vim
is the file we’re looking for.Search for
StatusLine
andStatusLineNC
(tip: you can do a whole word search in Vim by running/\<StatusLine\>
), and note the values used (you might have to jump through a few variables if the color scheme author decided to be fancy). You’re interested inctermbg
,ctermfg
,guibg
, andguifg
.You might find something like this:
hi StatusLine ctermbg=24 ctermfg=254 guibg=#004f87 guifg=#e4e4e4 hi StatusLineNC ctermbg=252 ctermfg=238 guibg=#d0d0d0 guifg=#444444
Copy those lines to your
~/.vimrc
. ChangeStatusLine
toStatusLineTerm
, and changeStatusLineNC
toStatusLineTermNC
:" Manually set the status line color. hi StatusLineTerm ctermbg=24 ctermfg=254 guibg=#004f87 guifg=#e4e4e4 hi StatusLineTermNC ctermbg=252 ctermfg=238 guibg=#d0d0d0 guifg=#444444
Reload
~/.vimrc
(:w | so %
), and the terminal mode status line should have the same colors as your color scheme:Above,
hi
is a shorthand forhighlight
, which is used to define highlight group colors.StatusLineTerm
andStatusLineTermNC
define the highlight groups for terminal mode status line (in active and inactive windows respectively). Optionsctermbg
andguibg
define the background color, andctermfg
andguifg
are responsible for the foreground (text) color. -
My book has been published!
Over the past six to nine months I’ve been working on a book - Mastering Vim. Mastering Vim is a passion project which is meant to take the reader (you) from zero to a hero (future you): from knowing nothing about Vim, to becoming a power user. I cover many of Vim’s mysterious commands, philosophy behind the beloved editor, configuration tips, a plethora of community created plugins, as well as creating your own plugins.
Mastering Vim was written with support from Packt Publishing and was kindly reviewed by Bram Moolenaar (website) - the creator of Vim. Many people made this book possible, including VimConf Japan crew, who kindly hosted me earlier this year. Thank you to everyone for making Mastering Vim happen!
Give it a read and let me know what you think, Mastering Vim is available on Amazon!
P.S: This post, like many others, is written in Vim.
-
Cross-platform vim-plug setup
I’ve recently switch to vim-plug, a lightweight Vim plugin manager.
It comes with a little
.vimrc
snippet which downloads the plugin, but it only works for Unix. I use Vim across all three platforms regularly, so I updated the snippet:" Download and install vim-plug (cross platform). if empty(glob( \ '$HOME/' . (has('win32') ? 'vimfiles' : '.vim') . '/autoload/plug.vim')) execute '!curl -fLo ' . \ (has('win32') ? '\%USERPROFILE\%/vimfiles' : '$HOME/.vim') . \ '/autoload/plug.vim --create-dirs ' . \ 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif
The above should work across all three major OSes, since Windows 10 recently received
curl
support. -
Minimalist phone launcher
For the past few years I’ve been trying to focus on having more mindful experiences in my life. I find it rewarding to be present in the moment, without my thoughts rushing onto whatever awaits me next.
I present to you the biggest distraction: my phone.
I use to get in touch with people I love. I’m more productive at work because I have access to information on the go. I also use my phone to browse Reddit, YouTube, and every other media outlet imaginable. Even worse, sometimes I just waste time tinkering with the settings or mindlessly browsing through the apps I have installed.
It’s an attention sink.
Nearly a year ago as I was browsing the Google Play Store I bumped into a new launcher: KISS. The tag line caught my attention: “Keep It Simple, Stupid”. I went ahead and downloaded the launcher. I haven’t changed to another launcher since.
Here’s how my home screen looks today:
There’s nothing besides a single search bar. The search bar takes me to the apps I need, web searches I’m interested in, or people I’m trying to reach out to.
It’s simple to use. Start typing an app or a contact name, and the results show up above the search bar:
This simple concept has been responsible for cutting hours upon hours from my phone usage. Opening an app becomes a more deliberate experience, I open my phone with a purpose (granted this purpose might be to kill hours looking at cat videos). There’s no more scrolling through everything I have installed just to find something to stimulate my attention for a few more seconds.
You can download the KISS Launcher for Android from Google Play Store.