Using vim, I would like to effectively have expandtabs
off if I'm to the left of any text on the line and on if I'm to the right of any non-whitespace character. (I would like to use tabs for indentation and spaces for alignment.)
Can this be done?
Yes. Use the Smart Tabs plugin.
This script allows you to use your normal tab settings for the beginning of the line, and have tabs expanded as spaces anywhere else. This effectively distinguishes 'indent' from 'alignment'.
<tab>
Uses editor tab settings to insert a tab at the beginning of the line (before the first non-space character), and inserts spaces otherwise.
<BS>
Uses editor tab settings to delete tabs or 'expanded' tabs ala smarttab
To make Vim line up function arguments, add
set cindent
set cinoptions=(0,u0,U0
to .vimrc
. The plugin will encode the whitespace as such:
int f(int x,
......int y) {
--->return g(x,
--->.........y);
}
This makes the alignment of "x
" and "y
" independent of the tab size (tabstop
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With