Besides Brian Rasmussen's (very good) answer, the only way I know almost exactly what you are asking is to use the mode virtualedit. This will not allow you to edit on non-existent lines, but it will allow you to edit outside existing lines. Therefore, to turn the current line into a load of # characters, you can do this:
:set virtualedit=all
v50lr
50x5, 4 , :
:set virtualedit=all
4o<ESC>
<C-V>4k50lr
( <C-V> Ctrl + V <ESC> Esc).
, , , , , .
- :
50i#<ESC>yyo#<ESC>48a<SPACE><ESC>a#<ENTER>#<SPACE><SPACE>My comment goes here<ESC>:exe<SPACE>'normal'<SPACE>(49-getpos('.')[2]).'a<SPACE>'<ENTER>a#<ENTER>#<ESC>48a<SPACE><ESC>a#<ESC>p
, ! , , , (:help - ).
: vimrc vim (, ~/.vim/plugins Unix)
nmap <F4> :InsertCommentBlock<CR>
command! InsertCommentBlock call InsertCommentBlock()
function! InsertCommentBlock()
let linelength = 50
let linelist = []
call add(linelist, repeat('#', linelength))
call add(linelist, '#' . repeat(' ', linelength-2) . '#')
let comment = input('Please enter a comment: ')
call add(linelist, '# ' . comment . repeat(' ', linelength - (4+len(comment))) . '#')
call add(linelist, '#' . repeat(' ', linelength-2) . '#')
call add(linelist, repeat('#', linelength))
call append(line('.'), linelist)
endfunction
:
:help function
:help 'virtualedit'
:help command
:help nmap
:help repeat()
:help append()
:help add()
:help getpos()
:help :exe
....