> On Thu, September 9, 2010 11:36 am, livim wrote:
>> I can't understand " It might be nice to have tabs after the first non-
>> blank inserted as spaces if you do this though. "
>> Who can give me some illustration?
>
> imap <expr> <tab> getline('.')[0:col('.')-1]=~'^\s*$'?'<tab>' : repeat(' ', &ts)
>
Cool. You lose the 'tabbyness', though. This modification adds a tab
(if no nonwhitespace so far) or enough spaces to put the cursor at the
next tabstop:
imap <expr> <tab> getline('.')[0:col('.')-1] !~ '\S' ? '<tab>'
\ : repeat(' ', &ts-((col('.')-1) % &ts))
To the OP, for an example of why the concept is useful, see the file
below, which is indented with tabs.
» indicates where <tab> was pressed to insert spaces when 'tabstop' was 6 (using the above mapping).
Set tabstop to different values:
:se ts=2
:se ts=9
to see that the vertically aligned '=' signs stay aligned.
===> simple-tab-example.c <===
int main(void) {
int i» = 10;
float f» = 20;
if (1) {
int asdf» = 1;
int j» = 1;
}
return 0;
}
/* vim:set listchars=tab\:│_ ts=6 sts=0: */
--
Best,
Ben
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment