Skip to content

Instantly share code, notes, and snippets.

@ak1103dev
Created January 21, 2018 10:54
Show Gist options
  • Save ak1103dev/9718a0b7059dca3908d24cb744057416 to your computer and use it in GitHub Desktop.
Save ak1103dev/9718a0b7059dca3908d24cb744057416 to your computer and use it in GitHub Desktop.
"*********************************************************************"
"" Basic Setup
"*********************************************************************"
"" Encoding
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
"" Fix backspace indent
set backspace=indent,eol,start
set list lcs=tab:\|\ "space"
"" Tabs. May be overriten by autocmd rules
set tabstop=2
set softtabstop=0
set shiftwidth=2
set expandtab
"" Map leader to ,
let mapleader=' '
"" Enable hidden buffers
set hidden
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
"" Encoding
set bomb
set binary
set ttyfast
"" Directories for swp files
set nobackup
set noswapfile
set fileformats=unix,dos,mac
set showcmd
set shell=/bin/sh
"" Patse & NoPaste
set pastetoggle=<F3>
"*********************************************************************"
"" Visual Settings
"*********************************************************************"
syntax on
set ruler
set number
let no_buffers_menu=1
set mousemodel=popup
set t_Co=256
set nocursorline
set guioptions=egmrti
set gfn=Monospace\ 10
"" Disable the blinking cursor.
set gcr=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
"*********************************************************************"
"" Abbreviations
"*********************************************************************"
"" no one is really happy until you have this shortcuts
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
"*********************************************************************"
"" Functions
"*********************************************************************"
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=79
endfunction
endif
"*********************************************************************"
"" Autocmd Rules
"*********************************************************************"
"" The PC is fast enough, do syntax highlight syncing from start
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync fromstart
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd FileType * set tabstop=2|set shiftwidth=2|set noexpandtab
autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
set autoread
"*********************************************************************"
"" Mappings
"*********************************************************************"
"" Split
noremap <Leader>h :<C-u>split<CR>
noremap <Leader>v :<C-u>vsplit<CR>
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment