20-Year Software and Exploring .vimrc Configs for File Opening, Syntax, and Search Highlighting

Books and Links

Completed The Intelligent Investor, this will be the 2nd book for the year.

When I wrote 2023 year end review, I had 7425 bookmarks, now Its 6629 - a 10% reduction.

Gmail is now 20 years old. Though I use many software, the following are the list of software that I use almost everyday, which are in the same league.

It takes at least 10 years to make a good software.

JavaScript, which wasn't even invented when I was born, is what pays my bills now. Who knows what the future holds? Learning and adopting new technology is the only way to be relevant in the future.

Vim

There are two things.

  1. Vim, the editor
  2. Vim motions

The easiest way to use Vim is to master the motions and practise before jumping right into using Vim, the editor. The next step is to start customizing the .vimrc, the Vim config file, as needed. Let's see some of the changes I made to my .vimrc file.

First, some basics: let's disable the nocompatible, disable swap and back file creation, show title and status line, highlight the cursor line and set encoding.


    set nocompatible
    set nobackup
    set noswapfile
    set history=1000
    set encoding=UTF-8

    set title
    set ls=2
    set cursorline

Let's display the line numbers on the gutter by default. relativenumber will be helpful for jumping from bottom to top.


    set relativenumber
    set number

Let's configure the search to search incrementally highlighting the matching characters we type and wrap around once we reach the end of file.

    
    set nowrap
    set ignorecase
    set smartcase
    set showmatch
    set hlsearch
    set incsearch
    set wrapscan

Let's now enable syntax for languages, add editor config and set colour code.


    syntax on

    filetype on
    filetype plugin on 
    filetype indent on 

    call plug#begin()
        Plug 'doums/darcula'
        Plug 'editorconfig/editorconfig-vim' "EditorConfigReload to reload configs
    call plug#end()

    colorscheme darcula "enable darcula theme, the closet to webstorm dark theme

Next, we need to start opening files in Vim.

    
    call plug#begin()
            Plug 'ctrlpvim/ctrlp.vim'
    call plug#end()

    let g:ctrlp_map = '<space><space>' " use double spaces instead of ⌘P
    let g:ctrlp_cmd = 'CtrlP'

    " auto completion for fuzzy matching
    set wildmenu
    set wildmode=list:longest
    set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx

Porting some of the utility I use in VScode.

    
 
    " moving lines up/down
    nnoremap <S-k> :m -2<CR>
    nnoremap <S-j> :m +1<CR>

And finally, some Vim specific tweaks

    
    " change block cursor when in insert mode
    let &t_SI = "\<Esc>]50;CursorShape=1\x7"
    let &t_SR = "\<Esc>]50;CursorShape=2\x7"
    let &t_EI = "\<Esc>]50;CursorShape=0\x7"
    
    set ttimeout
    set ttimeoutlen=1
    set listchars=tab:>-,trail:~,extends:>,precedes:<,space:.
    set ttyfast

    " disable arrow keys
    for key in ['<Up>', '<Down>', '<Left>', '<Right>']
        exec 'noremap' key '<Nop>'
        exec 'cnoremap' key '<Nop>'
    endfor

To check my current .vimrc configs, head over to sridharrajs/dotfiles/blob/master/.vimrc


For my new posts, Subscribe via weekly RSS, common RSS or Subscribe via Email