Rizal Farok _gvrimrc file

last updated April 2018. note that this is not my full file, since my mappings especially, has too much of cursor movement (<left>, <up>, <tab>, etc)


:start				" start GVIM in insert mode
set autoread			" Set to auto read when a file is changed from the outside
"set mat=2			" how many tenths of a second to blink matching brackets
"set showmatch			" When a bracket is inserted, briefly jump to the matching one
set matchpairs=[:]		" Matching pair characters
:NoMatchParen			" turn off matching pairs in v7
":DoMatchParen			" turn on in v7
"set nowrap			" Do not visually wrap long lines
set nu				" Line numbering in gvim
set vb				" turn off the beep sounds with visual bell

set nobackup			" Do not make a backup before overwriting a file
set nowritebackup		" don't keep a backup copy during the edit session
set noswapfile			" don't create a swap file
set noundofile			" don't create un~ (undo) file

set ruler			" Show the line and column number of the cursor position
"set showcmd			" Show (partial) command in status line
"au GUIEnter * simalt ~x	" Start givm maximized
set columns=156 lines=76	" When minimized, will be of this size
"set guioptions=Tmrbh		" T=toolbar m=menu r=right l=left b=bottom
"set guioptions+=b		" start with bottom scrollbar
"set cursorline			" highlight cursor position across
"set cursorcolumn		" highlight cursor position down

"set expandtab			" Do not insert tab when <Tab> was pressed - insert a number of spaces
set tabstop=4			" Number of spaces that a <Tab> in the file counts for
set softtabstop=4		" Number of spaces that a <Tab> counts for while performing editing operations
set shiftwidth=4		" Number of spaces to use for each step of (auto)indent
"set textwidth=256		" Maximum width of text that is being inserted. A longer line will be broken.
set smartindent			" Smart indent
set cindent			" Turn on C indenting
"set backspace=2		" Backspace over indent, eol, start
set notextmode			" Don't append bloody carriage returns
set history=50			" Command line history

syntax on			" syntax highlighting
syntax sync fromstart

set nohlsearch			" Stop the search highlighting
set ignorecase			" Ignore case in search patterns
set incsearch			" show the 'best match so far' as search strings are typed

au BufRead,BufNewFile *.tpl,*.php,*.twig,*tsx set filetype=smarty
autocmd FileType smarty,javascript,ss set formatoptions+=tl

highlight normal guibg=black guifg=white
highlight smartyProperty guifg=#8ad459
highlight smartyTagName guifg=#8ad459
highlight smartyBlock guifg=#8ad459
highlight smartyZone guifg=#8ad459

"set encoding=utf-8
set guifont=Monaco:h8

" ========================
" correct my common typos without me even noticing them:
" ========================
ab teh the
ab widht width
ab hegiht height
ab beign begin
ab colsapn colspan
ab colro color
ab decoartion decoration
ab assing assign
ab taht that
ab flase false

" ========================
" CSS HTML SMARTY Mappings
" ========================
set timeout timeoutlen=1000 " Set timeout on mappings/keycodes to 1 second

inoremap !min min-height:100px;height:auto!important;height:100px;
inoremap !bg background:<space>#fff<space>url()<space>left<space>top<space>no-repeat;
inoremap !mp margin:0;padding:0;
inoremap !target target="_blank" rel="noopener noreferrer"
inoremap !fil filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;
inoremap !test background:#000;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;
inoremap !bod -webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;

inoremap = =""<left>
inoremap == ==<space>
inoremap =<space> =<space>
inoremap != !=<space>
inoremap <br <br<space>/>

inoremap &n &nbsp;
inoremap &l &laquo;
inoremap &r &raquo;

inoremap !r background:red;
inoremap !g background:green;
inoremap !b background:blue;
inoremap !y background:yellow;
inoremap !bc background-color: rgba(0,0,0, 0.5);

inoremap <F5> <C-O>:sp<CR>
inoremap <C-F> <C-O>:promptfind<CR>
inoremap <C-R> <C-O>:promptrepl<CR>
inoremap <C-T> <C-O>:browse tabnew<CR>
inoremap <C-Q> <C-O>:%retab!<CR>
inoremap <C-W> <C-O>:%s=\s\+$==<CR>

" save session to a file
inoremap <F11> <C-O>:mksession! C:\vim\zzz<CR>
inoremap <F12> <C-O>:source C:\vim\zzz<CR>

" pressing < or > and tab will let you indent/unindent selected lines
vnoremap < <gv
vnoremap > >gv
vmap <tab> >gv

" ========================
" toggle case in insert mode
" ========================
function! TwiddleCase(str)
	if a:str ==# toupper(a:str)
		let result = tolower(a:str)
	elseif a:str ==# tolower(a:str)
		let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
	else
		let result = toupper(a:str)
	endif
	return result
endfunction
vnoremap ~ ygv"=TwiddleCase(@")<CR>Pgv