Skip to content

Instantly share code, notes, and snippets.

@soomtong
Last active April 16, 2023 14:41
Show Gist options
  • Save soomtong/0bd7e0187255bc6bf8fd2c8c0e8dc33f to your computer and use it in GitHub Desktop.
Save soomtong/0bd7e0187255bc6bf8fd2c8c0e8dc33f to your computer and use it in GitHub Desktop.
vanilla vim rc file
let mapleader="\<SPACE>"
inoremap jk <ESC>
nnoremap <SPACE> <Nop>
nnoremap <Leader>w :wa<CR>
nnoremap <leader>q :qa<Enter>
nnoremap <leader>h :set hlsearch! hlsearch?<CR>
" Buffer
nnoremap <Tab> :bnext!<Enter>
nnoremap <S-Tab> :bprevious!<Enter>
nnoremap <Leader>1 :buffer 1<Enter>
nnoremap <Leader>2 :buffer 2<Enter>
nnoremap <Leader>3 :buffer 3<Enter>
nnoremap <Leader>4 :buffer 4<Enter>
nnoremap <Leader>5 :buffer 5<Enter>
nnoremap <Leader>6 :buffer 6<Enter>
nnoremap <Leader>7 :buffer 7<Enter>
nnoremap <Leader>8 :buffer 8<Enter>
nnoremap <Leader>9 :buffer 9<Enter>
nnoremap <Leader>x :bdelete<Enter>
nnoremap <leader>gx :%bd<bar>e#<bar>'"<Enter>
" Moving
nnoremap gh 0
nnoremap gl $
inoremap <C-F> <Right>
inoremap <C-B> <Left>
inoremap <C-E> <End>
inoremap <C-A> <Home>
" Cursor move regardless word wrap
noremap j gj
noremap k gk
" Stay in indent mode
vnoremap < <gv
vnoremap > >gv
" Change directory
nnoremap <Leader>cd :cd %:p:h<CR>:pwd<CR>
" Global setup
set mouse=n
set nomousefocus
set termguicolors
set list listchars=tab:·\ ,trail:·,extends:>,precedes:<
set list
set pastetoggle=<F4>
syntax on
filetype plugin indent on
" Set temporary files:
"set nobackup
"set noswapfile
"set noundofile
set backupdir=/tmp//
set directory=/tmp//
set undodir=/tmp//
" zi to toggle fold
" zm, zM, zr, zR
set foldmethod=indent
set foldopen=all
set nofoldenable
set nu
set ruler
set encoding=utf8
set ffs=unix,dos,mac
set ignorecase
set smartcase
" Share system clipboard to yank
" set clipboard=unnamedplus
set autoread " detect when a file is changed
set tabstop=4
set shiftwidth=4
set si
set wrap
set hls
set cursorline
" set cursorcolumn
" Change cursor shape between insert and normal mode in iTerm2
if $TERM_PROGRAM =~ "iTerm"
let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
endif
if filereadable('~/.abbr')
source ~/.abbr
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment