Le samedi 28 juin 2014 à 11:33, Bruno Sutic a écrit:
> Hi,
> I would like to use tabs for indentation and spaces for alignment.
> This "idea" is also described here: http://vim.wikia.com/wiki/Indent_with_tabs%2C_align_with_spaces#Smart_tabs
>
> To put it simple:
> - tabs should be used at the beginning of the line
> - spaces should be inserted when after any character in the line
>
> The article linked above proposes a 'smart tab' plugin to achieve this. Unfortunately, this plugin breaks snipmate plugin which also uses tab.
>
> So I wonder, is there a way (an option maybe) to achieve this without a plugin?
> I tried `:h 'smarttab'`, but that does something else.
Try this:
function! s:TabOrSpace ()
let c = col(".")
if c == 1 || getline(".")[c-2] =~ '\t'
return "\t"
else
return " "
endif
endfunction
inoremap <expr> <Tab> <SID>TabOrSpace()
Then <Tab> (you can change the key, of course) will insert a tab if at
the beginning of the line or after a tab, and a space (you can make it
return more) otherwise.
I'm not 100% sure that's what you want, but I hope it helps anyway.
Best,
Paul
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment