specky/plugin/specky.vim
branchvim-stuff
changeset 3 db3e3abfc647
parent 2 6b33188f1694
child 5 3346aa8d5364
--- a/specky/plugin/specky.vim	Sun Mar 22 00:39:19 2009 +0000
+++ b/specky/plugin/specky.vim	Sun Mar 22 00:49:45 2009 +0000
@@ -16,6 +16,10 @@
 	execute 'map ' . g:speckyQuoteSwitcherKey . ' :call <SID>QuoteSwitcher()<CR>'
 endif
 
+if exists( 'g:speckyBannerKey' )
+	execute 'map ' . g:speckyBannerKey . ' :call <SID>MakeBanner()<CR>'
+endif
+
 if exists( 'g:speckyRunSpecKey' )
 	execute 'map ' . g:speckyRunSpecKey . ' :call <SID>RunSpec()<CR>'
 endif
@@ -39,6 +43,7 @@
 execute 'menu ' . s:menuloc . '.Run\ &spec :call <SID>RunSpec()<CR>'
 execute 'menu ' . s:menuloc . '.&RDoc\ lookup :call <SID>RunRdoc()<CR>'
 execute 'menu ' . s:menuloc . '.Rotate\ &quote\ style :call <SID>QuoteSwitcher()<CR>'
+execute 'menu ' . s:menuloc . '.Make\ a\ &banner :call <SID>MakeBanner()<CR>'
 
 
 " }}}
@@ -114,23 +119,23 @@
 	if l:type == '"'
 		" Double quote to single
 		"
-		execute ":normal viWs'" . l:word . "'"
+		execute ":normal viWc'" . l:word . "'"
 
 	elseif l:type == "'"
 		if &ft == "ruby"
 			" Single quote to symbol
 			"
-			execute ':normal viWs:' . l:word
+			execute ':normal viWc:' . l:word
 		else
 			" Single quote to double
 			"
-			execute ':normal viWs"' . l:word . '"'
+			execute ':normal viWc"' . l:word . '"'
 		end
 
 	else
 		" Whatever to double quote
 		"
-		execute ':normal viWs"' . l:word . '"'
+		execute ':normal viWc"' . l:word . '"'
 	endif
 
 	" Move the cursor back into the cl:word
@@ -140,6 +145,23 @@
 
 
 " }}}
+" MakeBanner() {{{
+"
+" Create a quick banner from the current line's text.
+"
+function! <SID>MakeBanner()
+	let l:banner_text = toupper(join( split( getline('.'), '\zs' ), ' ' ))
+	let l:banner_text = substitute( l:banner_text, '^\s\+', '', '' )
+	let l:sep = repeat( '#', 72 )
+	let l:line = line('.')
+
+	call setline( l:line, l:sep )
+ 	call append( l:line, [ '### ' . l:banner_text, l:sep ] )
+	call cursor( l:line + 3, 0 )
+endfunction
+
+
+" }}}
 " RunSpec() {{{
 "
 " Run this function while in a spec file to run the specs within vim.