2

I'm using vim-easy-align plugin and when in bash scripts I try to align $ at the beginning of variable names, the aligning adds spaces around the delimiter, i.e. <space>$<space> which of course makes those variables meaningless.

Are there options or tips to temporarily or permanently disable this? for specific delimiters? That is, to allow spaces around = and other delimiters, but not the variable leaders such as $.

Should I make a \$\w regex instead of just using the $?

  • 1
    What happens if you add $ to the iskeyword option (for sh files) ? – VanLaser Dec 4 '15 at 17:52
  • Thanks for the tip, but doesn't work. I used set iskeyword=@,$ with a shell file open and there was no difference in the easy-align results - still space on either side. Same spacey thing with = signs and other characters used. – Cometsong Dec 7 '15 at 14:46
  • ok, I've now figured out that the plugin has other variables to set the margins on each side of the character to align. I'll need to create a special function for all uses to make default left and right margins=0. – Cometsong Dec 7 '15 at 14:53
1

FileType solution, just for reference to whoever can use it....

"---- Easy Align ---- {{{
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)

augroup FileType sh,perl
  let g:easy_align_delimiters = {
      \ 's': {
      \     'pattern':       '\$',
      \     'ignore_groups': ['Comment'],
      \     'left_margin':   0,
      \     'right_margin':  0,
      \     'indentation':   'shallow',
      \     'stick_to_left': 0
      \     },
      \ '=': {
      \     'pattern':       '=',
      \     'ignore_groups': ['Comment'],
      \     'left_margin':   0,
      \     'right_margin':  0,
      \     'indentation':   'deep',
      \     'stick_to_left': 0
      \     }
  \}
  augroup END
"}}}

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.