Detailed view of a page, which is probably more useful for debugging than anything else.
get_pagedata('SuperRetab') | |
_cached_html | transformedtext Object ( [_type] => pagetype_wikitext Object ( ) [_basepage] => SuperRetab [_content] => Array ( [0] => <div class="wikitext"><hr /> <h3>The Challenge</h3> <p class="tightenable top">The challenge is to write a function that redoes the tabbing only along the left side of the text. It is a ranged function that takes a single parameter which is the # of spaces used to represent a single indent in the file.</p> <p class="tightenable bottom">The differences between this and the standard retab are</p> <ol><li class="tightenable top bottom">it takes a parameter for the # of spaces to equal a tab (doesn't use tabstop)</li> <li class="tightenable top">it only replaces groups of spaces at the start of a line.</li> </ol> <p class="tightenable bottom">So it could take a file that looks like</p> <pre class="tightenable top"> for { that; }</pre> <p class="tightenable">and turn it into (|------- represents a tab char) via :call [1] => cached_wikilink Object ( [_page] => SuperRetab ) [2] => (2)</p> <pre class="tightenable"> |-------for { |-------|-------that; |-------}</pre> <p class="tightenable bottom">and could create the same output from</p> <pre class="tightenable top bottom"> for { that; }</pre> <p class="tightenable top bottom">via :call [3] => cached_wikilink Object ( [_page] => SuperRetab ) [4] => (5)</p> <hr /> <hr /> <p class="tightenable bottom"> [5] => cached_wikilink Object ( [_page] => p0g ) [6] => 's attempt: (I think we have a winner here! -- [7] => cached_userlink Object ( [_page] => MetaCosm ) [8] => )</p> <pre class="tightenable top"> function! [9] => cached_wikilink Object ( [_page] => SuperRetab ) [10] => (width) range exe a:firstline . ',' . a:lastline . 's/\v%(^ *)@<= {'. a:width .'}/\t/g' endfunction OR as a command: :command! -nargs=1 -range [11] => cached_wikilink Object ( [_page] => SuperRetab ) [12] => <line1>,<line2>s/\v%(^ *)@<= {<args>}/\t/g</pre> <p class="tightenable">Cleaned up function by [13] => cached_wikilink Object ( [_page] => FallingCow ) [14] => (*Wow, much better -- [15] => cached_userlink Object ( [_page] => MetaCosm ) [16] => )</p> <p class="tightenable bottom"><i>version 1</i></p> <pre class="tightenable top"> function! [17] => cached_wikilink Object ( [_page] => SuperRetab ) [18] => () range let x = 0 while x < 10 exe a:firstline . ',' . a:lastline . 's/^\([ ]*\)[ ]\{' . &sw . '}/\1\t\2/e' let x = x + 1 endwhile endfunction</pre> <p class="tightenable bottom"><i>version 2</i></p> <pre class="tightenable top"> function! [19] => cached_wikilink Object ( [_page] => SuperRetab ) [20] => (width) range let x = 0 while x < 10 exe a:firstline . ',' . a:lastline . 's/^\([ ]*\)[ ]\{' . a:width . '}/\1\t\2/e' let x = x + 1 endwhile endfunction</pre> <p class="tightenable bottom"><i>version 3</i></p> <pre class="tightenable top"> function! [21] => cached_wikilink Object ( [_page] => SuperRetab ) [22] => (width) range let @" = '' redir @" while @" !~ 'E486:' silent! exe a:firstline . ',' . a:lastline . 'g/^\([ ]*\)[ ]\{' . a:width . '}/s//\1\t\2/' endwhile endfunction</pre> <p class="tightenable bottom"> [23] => cached_wikilink Object ( [_page] => Tofer ) [24] => 's Attempt</p> <pre class="tightenable top"> fun! F(len) let re = '^\(\( \{a:len}\)*\) \{a:len}' let n = 1 while n <= line("$") let l = getline(n) while l = re let l = substitute(l,re,"\\1\\t","") endwhile call setline(n,l) let n = n + 1 endwhile endfunc</pre> <p class="tightenable bottom"> [25] => cached_userlink Object ( [_page] => MetaCosm ) [26] => 's Attempt (mine doesn't take a range and is put to shame by those below it, only reason it is left here is for history.)</p> <pre class="tightenable top bottom"> function! [27] => cached_wikilink Object ( [_page] => SuperRetab ) [28] => (width) let n = 1 while n <= line("$") "echo "Outer Loop:".n let i = 30 " hardcoded max of 30 deep indent while i >= 1 let numberOfSpaces = a:width * i "echo " Inner Loop".i." :: ".numberOfSpaces let j = 1 let spaces = "^ " while j < numberOfSpaces let spaces = spaces . " " let j = j + 1 endwhile let k = 1 let tabs = "" while k < numberOfSpaces let tabs = tabs . "\t" let k = k + a:width endwhile "echo "s/" . spaces . "/" . tabs . "/" let l = substitute(getline(n), spaces, tabs, "") call setline(n, l) let i = i - 1 endwhile let n = n + 1 endwhile endfunction</pre> </div> ) [_description] => The challenge is to write a function that redoes the tabbing only along the left side of the text. It is a ranged function that takes a single parameter which is the # of spaces used to represent a single indent in the file. ) |
hits | 4433 |
get_versiondata('SuperRetab',33) | |
%content | ---- !!The Challenge The challenge is to ... |
author | 216.47.158.208 |
author_id | 216.47.158.208 |
is_minor_edit | 1 |
markup | 2 |
mtime | 1195238647 |
pagetype | wikitext |
summary | reverted spam away |
get_versiondata('SuperRetab',32) | |
%content | ---- !!The Challenge The challenge is to ... |
_supplanted | 1195238647 |
author | WikiWord |
author_id | WikiWord |
is_minor_edit | |
markup | 2 |
mtime | 1186719048 |
pagetype | wikitext |
get_versiondata('SuperRetab',31) | |
%content | ---- !!The Challenge The challenge is to ... |
_supplanted | 1186719048 |
author | WikiWord |
author_id | WikiWord |
is_minor_edit | |
markup | 2 |
mtime | 1186711921 |
pagetype | wikitext |
get_versiondata('SuperRetab',30) | |
%content | ---- !!The Challenge The challenge is to ... |
_supplanted | 1186711921 |
author | 194.94.79.49 |
author_id | 194.94.79.49 |
is_minor_edit | 1 |
markup | 2 |
mtime | 1184343480 |
pagetype | wikitext |
get_versiondata('SuperRetab',26) | |
%content | ---- !!The Challenge The challenge is to ... |
_supplanted | 1183061277 |
author | 65.242.74.195 |
author_id | 65.242.74.195 |
is_minor_edit | 1 |
markup | 2 |
mtime | 1084217648 |
pagetype | wikitext |