Skip to content

Instantly share code, notes, and snippets.

@GeordieP
Last active March 28, 2018 16:08
Show Gist options
  • Save GeordieP/ccfc0b69db3ec6504e3e4a9678cb5fa4 to your computer and use it in GitHub Desktop.
Save GeordieP/ccfc0b69db3ec6504e3e4a9678cb5fa4 to your computer and use it in GitHub Desktop.
gp portable vimrc
"==========================
" visuals
"==========================
set title
set titleold="Terminal"
set titlestring=%F
set guioptions=egmrti
set gcr=a:blinkon0
set scrolloff=5
set laststatus=2
set modeline
set modelines=10
set hidden
set nowrap
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
set cursorline
"==========================
" lines
"==========================
syntax on
set ruler
set number
"==========================
" encoding
"==========================
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set bomb
set binary
"==========================
" interaction
"==========================
set mousemodel=popup
" cause ctrl+w to always delete previous word (instead of only words entered
" since beginning of current insert mode)
set backspace=indent,eol,start
set mouse=nicr " fix mouse for iTerm2
"==========================
" indentation
"==========================
set tabstop=4
set softtabstop=0
set shiftwidth=4
set expandtab
set backspace=indent,eol,start
"==========================
" searching
"==========================
" set hlsearch " enable highlighting of search results - bound to key in keys.vim
set nohlsearch "disable search highlighting (it's on by default)
set incsearch
set ignorecase
set smartcase
"==========================
" files
"==========================
set nobackup
set noswapfile
set fileformats=unix,dos,mac
set autoread
"==========================
" keys
"==========================
" map leader ,
let mapleader=','
" buffer nav
noremap <leader>z :bp<CR>
noremap <leader>q :bn<CR>
nnoremap <silent> <C-Tab> :bn<CR>
nnoremap <silent> <C-S-Tab> :bp<CR>
" close buffer
noremap <leader>c :bd<CR>
" switching windows
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <C-h> <C-w>h
"
" clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
" press enter to clear search highlight
nnoremap <cr> :noh<cr>
" enter normal mode
inoremap kj <Esc>
" delete previous word ctrl+backspace
imap <C-BS> <C-W>
" Opens an edit command with the path of the currently edited file filled in
noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Opens a tab edit command with the path of the currently edited file filled
noremap <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
" set cwd to current file cwd
nnoremap <leader>. :lcd %:p:h<CR>
" next tab
nnoremap <Tab> gt
" prev tab
nnoremap <S-Tab> gT
" create tab
nnoremap <silent> <C-t> :tabnew<CR>
" horiz split
noremap <Leader>sh :<C-u>split<CR>
" vert split
noremap <Leader>v :<C-u>vsplit<CR>
" toggle relative line numbers
noremap <S-t> :set relativenumber!<cr>
" center view on next find result
nnoremap n nzzzv
" center view on prev find result
nnoremap N Nzzzv
" abbrev case insensitivity
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
" close buffer in current split without losing split
nnoremap <silent> <leader>x :b #\|:bd #<CR>
nmap <C-_> gcc
" leader,ctrl-h to toggle search highlighting
nnoremap <leader><C-h> :set hls!\|set hls?<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment