Hello,

Lev Lvovsky <[EMAIL PROTECTED]> wrote:

> how can I align text under and after the cursor position to a
> specific column number?  and probably just as important, how can I
> find out which column number a cursor is at ;)?

In an unreleased plugin, I have the following definitions


----- >% -----
" take the cursor wherever you want and type "42,\mc"
nnoremap <leader>mc :<c-u>call <sid>MoveToCol()<cr>

function! s:MoveToCol()
  let d = v:count - col('.')
  if d > 0
    exe 'normal! '.d."i \<esc>"
  endif
endfunction

" use repeat() with vim7 instead
function! RepeatNChar(times, char)
  let r = ''
  let i = 0
  while i != a:times
    let r = r . a:char
    let i = i + 1
  endwhile
  return r
endfunction

function! CompleteWithUpToCol(with, column)
  return RepeatNChar( a:column-col('.'), a:with)
endfunction

----- >% -----

The last function can be used with:
- Align the arguments that follow the first comma
  :%s#,\zs#\=CompleteWithUpToCol('~', 42)
- Align the the equal signs
  :%s#\ze=#\=CompleteWithUpToCol(' ', 50)


HTH,

--
Luc Hermitte

Reply via email to