4

I've created several keys and each key is working fine.
Want to find a way to do multiple alignments with single command. Like to create a key mapping, when it's running it can align the specific characters in sequence.
map <leader>vga first align all space, then align all (, last align all ).

example example (
   .a (a),
   .ab (ab),
   .abc (abc)
);

Expected output

example example (
   .a   ( a   ),
   .ab  ( ab  ),
   .abc ( abc )
);

easy_align_delimiters definitions:

    let g:easy_align_delimiters = {
...
    \ '(': {
    \     'pattern':       '[(]',
    \     'left_margin':   1,
    \     'right_margin':  1,
    \     'stick_to_left': 0
    \   },
    \ ')': {
    \     'pattern':       '[)]',
    \     'left_margin':   1,
    \     'right_margin':  0,
    \     'stick_to_left': 0
    \   },
...
  • But that would not work anyway, would it? First if you align with space, and then you align with ( then the previous alignment would be destroyed. – klaus Jun 15 '18 at 16:05
  • 5
    This question would benefit greatly from an example – DJMcMayhem Jun 15 '18 at 16:43
  • @DJMcMayhem, Previous alignment won't get lost if you align with another character. – Fisher Jun 18 '18 at 8:07
  • I think your previous comment was meant for me :) – klaus Jun 18 '18 at 8:13
0

Below shortcut and function will do the job.

map <leader>vga :call Vhdl_GA_All()<CR>

" Alignment
function! Vhdl_GA_All()
   exe "normal! \e"
   exe ":'<,'> EasyAlign *<space>"
   exe ":'<,'> EasyAlign ("
   exe ":'<,'> EasyAlign )"
endfunction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.