Created
February 1, 2012 08:25
-
-
Save Phize/1715941 to your computer and use it in GitHub Desktop.
align comment(s) with Align Them All! plugin on Vim.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" return regexp pattern that matches a comment based on commentstring. | |
function! s:getCommentStringPattern() | |
let pattern = escape(&commentstring, '^$[].*\~ ') | |
let pattern = substitute(pattern, '%s', '.*', 'g') | |
return pattern | |
endfunction | |
" align comment(s) based on commentstring. | |
autocmd vimrc-autocmd BufEnter * | |
\ execute 'nnoremap <silent> <Leader>a/ :<C-u>Alignta v/^\s*' . s:getCommentStringPattern() . ' <-- -r ' . s:getCommentStringPattern() . '<CR>' | | |
\ execute 'vnoremap <silent> <Leader>a/ :Alignta v/^\s*' . s:getCommentStringPattern() . ' <-- -r ' . s:getCommentStringPattern() . '<CR>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment