Skip to content

Instantly share code, notes, and snippets.

Some may be more advanced than others, and some are vi only...
Vim Tutorials
=============
* http://blog.smr.co.in/linux/advanced-vim-tutorial/
* http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html
* http://www.derekwyatt.org/vim/vim-tutorial-videos/vim-advanced-tutorial-videos/
* http://linuxgazette.net/152/srinivasan.html
* http://www.eng.hawaii.edu/Tutor/vi.html
@dahu
dahu / .vimrc [sample]
Created May 18, 2011 22:38
sample of my vimrc options
""""""""""
" Options
""""""""""
" Use :help 'option (inclduing the ' character) to learn more about each one.
"
" Buffer (File) Options:
set hidden " Edit multiple unsaved files at the same time
set confirm " Prompt to save unsaved changes when exiting
" Keep various histories between edits
set viminfo='1000,f1,<500,:100,/100
@dahu
dahu / vim_regex_way_rationale.txt
Created August 7, 2011 03:22
Vim's Way of the Regex
NOTE: Some of Vim's way of handling certain regex features differs from
PCRE. Some people complain about this and wonder why Vim didn't just use the
already existing PCRE way. The reason is that Vim started getting some of
these things at the same time Perl did, or even beforehand. So, it's not
that Vim decided to flout history and Go Its Own Way just to be difficult.
Respect that Vim -can- do these things and has been able to do so for a long
time now; and suck it up and learn Vim's way. :-)
@dahu
dahu / gist:2101008
Created March 19, 2012 07:34
Vim - Disable certain plugins if number of lines in file too numerous
" disable the syntastic plugin if editing a file more than 700 lines long
function DisablePlugins()
if line('$') > 700
let g:loaded_syntastic = 1
endif
endfunction
au BufRead * call DisablePlugins()
@dahu
dahu / gist:2297202
Created April 4, 2012 02:30
Update Timestamp on BufWrite
" Update a timestamp on BufWrite
" Barry Arthur, 2012 04 04
function! UpdateTimestamp()
let old_pos = getpos('.')
let old_search = histget("search", -1)
g/^# \d\{4}-\d\d-\d\d \d\d:\d\d: \.0 +\d\{4} \/\s*sputnick/s/^.\{-}\/\s*sputnick\s*$/\="# " . strftime('%F %H:%M: .0 %z') . " \/ sputnick"/
exe "normal /".old_search
call setpos('.', old_pos)
endfunction
@dahu
dahu / gist:2306173
Created April 4, 2012 22:33
Vim startinsert example
func! Foo()
call setline('.', "s///")
call setpos('.', [0, 1, 3, 0])
startinsert
endfunc
@dahu
dahu / gist:2324560
Created April 7, 2012 02:23
runVimTestsSetup.vim
function! PrependToRTP(name)
let &runtimepath = a:name . ',' . &rtp
endfunction
" Prepend tests repos to &rtp
call PrependToRTP(expand('$HOME').'/projects/vim/plugins/runVimTests')
call PrependToRTP(expand('$HOME').'/projects/vim/plugins/vimtap')
" Glabal vars for commonly tested plugins
let runVimTests_common = {}
@dahu
dahu / gist:2380733
Created April 13, 2012 23:14
three way split with NT, TB and me
NERDTree
TagbarOpen
wincmd p
wincmd J
exe 2 . "wincmd w"
wincmd L
@dahu
dahu / gist:2427305
Created April 20, 2012 09:20
Houl's UniqMap
" Original Code by Houl
" Refactored by Barry Arthur, 20 Apr 2012
" UniqMapFirst({list}, {map-expr})
"
" Remove duplicates from {list}, after applying {map-expr} (see :h map()).
" The instance with the lowest index is kept.
"
function! UniqMapFirst(list, mapexpr) "{{{
let mlist = map(copy(a:list), a:mapexpr)
@dahu
dahu / gist:2434854
Created April 21, 2012 06:40
semicolon vs comma in vim
EXPORT
this
EXPORT
abc
here