Wikia

Vim Tips Wiki

Script:294

Talk0
1,610pages on
this wiki

Use this page to discuss script 294 Align: align text, eqns, declarations, tables

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

InstallEdit

Make sure you have the newest version of Vimball installed or it will bork in weird ways. --March 9, 2012

CommentsEdit

I'd like to roll \adef and \adec into my personal crazy block formatting approach like this (I don't like to learn new mappings but make fuzzy additions to my own):

" Try to reformat the entire current paragraph. Fails many ways of course. nnoremap ;f :call DoAppropriateBlockFormatter()<CR> function! DoAppropriateBlockFormatter()

 if &ft == "c" && (match(getline("."), '#') != -1)
   call feedkeys("{V}\\adef", 't')
 elseif &ft == "vim" || &ft == "c" || &ft == "perl" || &ft == "sh" ||
   \ &ft == "make" || &ft == "conf"
   call FormatBlockComment()
 else
   call feedkeys("{gq}")
 endif

endfunction

This took some time to get right because of the need for two backslashes to feedkeys. It would be nice to call \adef as a function, but it seems that it only exists as a key binding to a rather unwieldy rhs:

map <silent> <script> <Plug>AM_adef <SID>WS:AlignPush<CR>:AlignCtrl v ^\s*\(\/\*\<bar>\/\/\)<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/^\(\s*\)#\(\s\)*define\s*\(\I[a-zA-Z_0-9(),]*\)\s*\(.\{-}\)\($\<Bar>\/\*\)/#\1\2define @\3@\4@\5/e<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/\($\<Bar>\*\/\)/@&/e<CR>'zk:call AlignMaps#StdAlign(1)<cr>'yjma'zk:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/ @//g<CR><SID>WE

It would be nice if there were functional entry points for the specific alignment stuff since the easiest parts of the formidable Align.vm to get started with :)

Around Wikia's network

Random Wiki