Sunday, May 2, 2010

Re: automatically move cursor to after comment leader

I've never scripted Vim before, but I took a stab at this. Here's a
version I put in my after/mail.vim. Could be better, especially the
fudged detection of whether or not the cursor is currently after the
comment leader, but it seems to work for now.

let g:linelist = [1]
:autocmd!
:autocmd CursorMoved * :call SkipCommentLeader()

function! SkipCommentLeader()
let currentlinenum = line(".")
:call insert(g:linelist,currentlinenum)
" if haven't changed lines, exit
if currentlinenum == g:linelist[1]
return 0
else
let currentline = getline(".")
let currentcolnum = virtcol(".")
"if line is a comment and cursor is near beginning
if currentline !~ "^>*\s*$" && currentcolnum < 3
"go to first alphanumeric character in line
call search('\w','c',".")
endif
endif
endfunction

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: