Permalink
Browse files

Add some normal mode mappings.

  • Loading branch information...
1 parent 63f67c3 commit dcca82348f7053116a7c8da749f0f12eeaf7137f @theIV theIV committed Mar 1, 2012
Showing with 30 additions and 14 deletions.
  1. +7 −7 README.md
  2. +23 −7 plugin/tomdoc.vim
View
14 README.md
@@ -2,10 +2,10 @@
Some helper functions to add TomDoc templates to your Ruby code.
-* TomDocMethod()
-* TomDocClass()
-* TomDocModule()
-* TomDocConstant()
-* TomDocAttrReader()
-* TomDocAttrWriter()
-* TomDocAttrAccessor()
+* TomDocMethod() -- mapped to normal tdm
+* TomDocClass() -- mapped to normal tdc
+* TomDocModule() -- mapped to normal tdmo
+* TomDocConstant() -- mapped to normal tdco
+* TomDocAttrReader() -- mapped to normal tdar
+* TomDocAttrWriter() -- mapped to normal tdaw
+* TomDocAttrAccessor() -- mapped to normal tdaa
View
30 plugin/tomdoc.vim
@@ -8,40 +8,56 @@ endif
let g:loaded_tomdoc = 1
let s:templates_dir = expand("<sfile>:p:h") . "/../templates/"
-function! TomDocMethod()
+function! s:TomDocMethod()
let lineNumber = search('def', 'b') - 1
exec ":" . lineNumber . "r" . s:templates_dir . "method.txt"
silent norm! '[=']
endfunction
-function! TomDocClass()
+function! s:TomDocClass()
let lineNumber = search('class', 'b') - 1
exec ":" . lineNumber . "r" . s:templates_dir . "class-or-module.txt"
silent norm! '[=']
endfunction
-function! TomDocModule()
+function! s:TomDocModule()
let lineNumber = search('module', 'b') - 1
exec ":" . lineNumber . "r" . s:templates_dir . "class-or-module.txt"
silent norm! '[=']
endfunction
-function! TomDocConstant()
+function! s:TomDocConstant()
exec ":-1r" . s:templates_dir . "constant.txt"
silent norm! '[=']
endfunction
-function! TomDocAttrReader()
+function! s:TomDocAttrReader()
exec ":-1r" . s:templates_dir . "attr_reader.txt"
silent norm! '[=']
endfunction
-function! TomDocAttrWriter()
+function! s:TomDocAttrWriter()
exec ":-1r" . s:templates_dir . "attr_writer.txt"
silent norm! '[=']
endfunction
-function! TomDocAttrAccessor()
+function! s:TomDocAttrAccessor()
exec ":-1r" . s:templates_dir . "attr_accessor.txt"
silent norm! '[=']
endfunction
+
+nnoremap <silent> <Plug>TDMethod :<C-U>call <SID>TomDocMethod()<CR>
+nnoremap <silent> <Plug>TDClass :<C-U>call <SID>TomDocClass()<CR>
+nnoremap <silent> <Plug>TDModule :<C-U>call <SID>TomDocModule()<CR>
+nnoremap <silent> <Plug>TDConstant :<C-U>call <SID>TomDocConstant()<CR>
+nnoremap <silent> <Plug>TDAttrReader :<C-U>call <SID>TomDocAttrReader()<CR>
+nnoremap <silent> <Plug>TDAttrWriter :<C-U>call <SID>TomDocAttrWriter()<CR>
+nnoremap <silent> <Plug>TDAttrAccessor :<C-U>call <SID>TomDocAttrAccessor()<CR>
+
+nmap tdm <Plug>TDMethod
+nmap tdc <Plug>TDClass
+nmap tdmo <Plug>TDModule
+nmap tdco <Plug>TDConstant
+nmap tdar <Plug>TDAttrReader
+nmap tdaw <Plug>TDAttrWriter
+nmap tdaa <Plug>TDAttrAccessor

0 comments on commit dcca823

Please sign in to comment.