Skip to content

Instantly share code, notes, and snippets.

View AndrewRadev's full-sized avatar

Andrew Radev AndrewRadev

View GitHub Profile
@AndrewRadev
AndrewRadev / wireless-on
Created July 3, 2011 19:53
Simple script to turn my wireless on
#! /bin/sh
rfkill unblock 0
/etc/rc.d/network stop
/etc/rc.d/networkmanager start
nm-applet &
@AndrewRadev
AndrewRadev / xorg.conf
Created July 3, 2011 20:00
X11 options for idling
Section "ServerFlags"
Option "blank time" "10" # Blank the screen (Fake)
Option "standby time" "15" # Turn off screen (DPMS)
Option "suspend time" "30" # Full suspend
Option "off time" "40" # Turn off
EndSection
@AndrewRadev
AndrewRadev / close_hidden.vim
Created July 6, 2011 12:22
Close all buffers that are not currently opened
command! CloseHiddenBuffers call s:CloseHiddenBuffers()
function! s:CloseHiddenBuffers()
" Get the output of :ls as a string
redir => ls_output
silent ls
redir END
" Go through all buffer entries
for line in split(ls_output, "\n")
if line =~ '\d\+\s*\S\+\s*".*"' " then the listing contains flags
@AndrewRadev
AndrewRadev / bundle_updater_for_vim
Created July 21, 2011 09:28 — forked from vladimiroff/bundle_updater_for_vim
Handy shell script for keeping my bundles in vim up-to date
cd $HOME/.vim/bundle/
for plugin in *; do
cd $plugin
echo ":: Updating $plugin ..."
if [ -d .git ]; then
git checkout master
git pull origin master
else
echo ":: $plugin is not managed as a submodule"
fi
nnoremap << :call <SID>KeepCursorAfterShift('<<', -1)<cr>
nnoremap >> :call <SID>KeepCursorAfterShift('>>', 1)<cr>
function! s:KeepCursorAfterShift(cmd, modifier)
let column = col('.')
exe "normal! ".a:cmd
call cursor(line('.'), column + a:modifier * &shiftwidth)
endfunction
@AndrewRadev
AndrewRadev / bufferize.vim
Created July 24, 2011 19:18
Load a vim command's output into a buffer
" For example:
"
" Bufferize digraphs
" Bufferize ls
"
command! -nargs=* -complete=command Bufferize call s:Bufferize(<f-args>)
function! s:Bufferize(...)
let cmd = join(a:000, ' ')
redir => output
silent exe cmd
@AndrewRadev
AndrewRadev / highlight_search.vim
Created July 29, 2011 09:10
Highlight trailing whitespace only in normal mode
autocmd! InsertLeave,WinEnter * call s:Highlight()
autocmd! InsertEnter * call s:Unhighlight()
hi link HighlightSpace Search
function! s:Highlight()
match HighlightSpace /\s\+$/
endfunction
function! s:Unhighlight()
match none
@AndrewRadev
AndrewRadev / split_json.vim
Created July 31, 2011 18:49
Pretty format a json file by using my splitjoin plugin
command! SplitJson call s:SplitJson()
function! s:SplitJson()
call cursor(1, 1)
call sj#js#SplitObjectLiteral()
while search('{', 'W') > 0
call sj#js#SplitObjectLiteral()
endwhile
call cursor(0, 0)
@AndrewRadev
AndrewRadev / README.markdown
Created August 11, 2011 16:45 — forked from skanev/README.markdown
Convert a <select> with <optgroups> to two <select>s that are interconnected

If you have a select with option groups:

<select data-nested-select="Select country">
  <option>Select city</option>
  <optgroup label="Bulgaria">
    <option value="sofia">Sofia</option>
    <option value="plovdiv">Plovdiv</option>
  </optgroup>
  <optgroup label="Sweden">

Stockholm

@AndrewRadev
AndrewRadev / LICENSE
Last active March 20, 2024 14:25
Execute a vim motion on the "next" text object
MIT License
Copyright (c) 2017 Andrew Radev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: