Skip to content

Instantly share code, notes, and snippets.

" Set b:formatprg to emulate a setlocal for formatprg
if exists('g:loaded_gq') || &cp || v:version < 700
finish
endif
let g:loaded_gq = 1
function! s:gq(type, ...)
let formatprg = &formatprg
let &formatprg = get(b:, 'formatprg', &formatprg)
if exists('b:loaded_phpthis') || &cp
finish
endif
let b:loaded_phpthis = 1
if !exists("b:undo_ftplugin")
let b:undo_ftplugin = ""
endif
function! s:synnames(...) abort
@PeterRincker
PeterRincker / css_fold.vim
Last active August 29, 2015 13:58
Fold multi-line CSS into one line CSS style. Use `>s` and `<s` to increase or decrease the width of the default selector field area. Save as ~/.vim/ftplugin/css_fold.vim
" Adapation form http://stackoverflow.com/a/1423394/438329
if exists('b:loaded_cssfold')
finish
endif
let b:loaded_cssfold = 1
let b:width = 25
nnoremap <silent> <buffer> >s :<c-u>let b:width+=v:count1<cr><c-l>
nnoremap <silent> <buffer> <s :<c-u>let b:width-=v:count1<cr><c-l>
@PeterRincker
PeterRincker / quick-replace.vim
Last active April 18, 2022 20:20 — forked from orlp/gist:8c25ed4abb36372bc6fe
Quick Replacements - gn with an n afterwards
" Quick Replace
" Makes *``cgn like workflows faster by automatically moving to next match. Repeat with `.`
"
" Requires repeat.vim
"
" Example mappings:
" nmap cm <Plug>(quick-replace)
" xmap C <Plug>(quick-replace)
"
" mnemonic: cm for change matches
@PeterRincker
PeterRincker / cupcake.txt
Created December 20, 2014 01:08
Cupcake - Simple SQL query runner
*cupcake.txt* SQL query runner
Author: Peter Rincker *cupcake-author*
License: Same terms as Vim itself (see |license|)
This plugin is only available if 'compatible' is not set.
==============================================================================
*cupcake*
@PeterRincker
PeterRincker / python.py
Created February 21, 2015 01:28
compiler/python.vim
#!/usr/bin/env python
# put this file at ~/.vim/compiler.py
from __future__ import print_function
from sys import argv, exit
if len(argv) != 2:
exit(1)
@PeterRincker
PeterRincker / comment.vim
Last active March 17, 2021 22:02
SimpleComment
" Inspired by Tim Pope's commentary.vim
"
" Uses b:commentstring or 'commentstring' as the comment pattern
" example:
" let &commentstring = '/*%s*/'
nnoremap gcc :<c-u>.,.+<c-r>=v:count<cr>call <SID>toggleComment()<cr>
nnoremap gc :<c-u>set opfunc=<SID>commentOp<cr>g@
xnoremap gc :call <SID>toggleComment()<cr>
@PeterRincker
PeterRincker / FancySmancyComment.vim
Created August 17, 2015 11:05
Center text inside of a comment
" FancySmancyComment(text, fill_char, width)
" Create comment string with centered text
" All arguments are optional
function! FancySmancyComment(...)
let text = get(a:000, 0, '')
let fill = get(a:000, 1, '-')[0]
let width = get(a:000, 2, 80) - len(printf(&commentstring, '')) - len(text)
let left = width / 2
let right = width - left
put=printf(&commentstring, repeat(fill, left) . text . repeat(fill, right))
@PeterRincker
PeterRincker / markdown-backtick.vim
Last active January 27, 2017 23:37
Backtick support for matchit in markdown files
" Put inside ~/after/plugin/matchit.vim
if exists('g:loaded_after_matchit') || !has('syntax') || &cp || v:version < 700
finish
endif
let g:loaded_after_matchit = 1
function! s:synnames(...) abort
if a:0
let [line, col] = [a:1, a:2]
else
@PeterRincker
PeterRincker / quick-php-man.vim
Created January 28, 2017 01:09
Show php signature
" put in ~/.vim/ftplugin/php_man.vim
" Will map K to show signature on commandline.
" Will also attempt to show signature while typing.
"
" Set g:php_quick_man_color = 0 to disable color
" Set g:php_quick_man_insert_mode = 0 to disable insert mode signature
if exists('b:ftplugin_php_man')
finish
endif