m (How to implement vertical lines showing tab groups.. moved to See the tabs in your file: Page moved by JohnBot to improve title) |
(Remove html character entities) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{review}} |
{{review}} |
||
+ | {{TipImported |
||
− | {{Tip |
||
|id=460 |
|id=460 |
||
+ | |previous=459 |
||
− | |title=how to implement vertical lines showing tab groups.. |
||
+ | |next=461 |
||
− | |created=April 21, 2003 |
+ | |created=April 21, 2003 |
|complexity=basic |
|complexity=basic |
||
|author=Robert (MetaCosm) |
|author=Robert (MetaCosm) |
||
|version=5.7 |
|version=5.7 |
||
|rating=90/38 |
|rating=90/38 |
||
+ | |category1= |
||
− | |text= |
||
+ | |category2= |
||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
− | [http://www.jedit.org/index.php?page=screenshot&image=10 http://www.jedit.org/index.php?page=screenshot&image=10] <-- show a much better example that my little example did... |
||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
− | :h listchars for help |
||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Hope this helps you... join #vim on irc.freenode.net for all your vim help needs :) |
||
}} |
}} |
||
⚫ | |||
+ | <pre> |
||
⚫ | |||
⚫ | |||
− | You could really use ANY char to do your vertical groups.... . and | tend to work very well |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | </pre> |
||
⚫ | |||
− | '''Anonymous''' |
||
− | , April 21, 2003 13:35 |
||
− | ---- |
||
⚫ | |||
+ | <pre> |
||
⚫ | |||
+ | :set listchars=tab:\|\<Space> |
||
+ | </pre> |
||
+ | ==References== |
||
− | '''Anonymous''' |
||
+ | *{{help|'listchars'}} |
||
− | , April 21, 2003 13:46 |
||
− | ---- |
||
− | I missed the trailing space after the backslash. So for people who missed it too......read the line above as - set listchars+=backslash-pipe-backslash-space |
||
⚫ | |||
− | Mohit Kalra |
||
+ | In order to tweak the colors |
||
− | , April 21, 2003 21:39 |
||
⚫ | |||
− | ---- |
||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | redir --AT--a |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | else |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | endif |
||
⚫ | |||
⚫ | |||
− | |||
− | |||
− | cec--AT--NgrOyphSon.gPsfAc.nMasa.gov |
||
− | , April 22, 2003 8:07 |
||
---- |
---- |
||
⚫ | |||
− | hey! but this wont work with expandtabs on! |
||
− | i would rather have expand tabs on because otherwise, if i ship my source to someone else who has a different tabstop, then all my indenting will get all messed up and lines will go beyond 80 and wrap around and what not... |
||
− | does anybody have a solution for this in an expand tabs scenario?? |
||
⚫ | |||
− | gowri.satyanarayana--AT--oracle.com |
||
− | , April 23, 2003 0:32 |
||
− | ---- |
||
⚫ | |||
− | |||
− | ############################### |
||
+ | <pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | end |
||
− | + | let g:SeeTabEnabled = 1 |
|
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | redir @a |
||
⚫ | |||
⚫ | |||
− | else |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | end |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | else |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | endif |
||
⚫ | |||
com! -nargs=0 SeeTab :call SeeTab() |
com! -nargs=0 SeeTab :call SeeTab() |
||
+ | </pre> |
||
− | bphelan--AT--mathworks.co.uk |
||
− | , April 24, 2003 2:11 |
||
---- |
---- |
||
⚫ | |||
− | Wow -- great comments on this tip. I am hoping to tie this wonderf comment together into a Script. Great work guys. The ability to work with expandtab is really wonderful! |
||
+ | <pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | end |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | else |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | end |
||
⚫ | |||
⚫ | |||
+ | </pre> |
||
− | Robert (MetaCosm) |
||
− | , April 24, 2003 10:38 |
||
---- |
---- |
||
− | + | One correction: expand tabs setting expands tabs according to the tabstop setting not shiftwidth - so in the SeeTab() function, replace &sw by &ts |
|
− | |||
− | gowri.satyanarayana--AT--oracle.com |
||
− | , April 24, 2003 22:12 |
||
− | ---- |
||
− | Gowri, |
||
− | |||
− | I've installed the script at |
||
− | |||
− | http://www.vim.org/scripts/script.php?script_id=627 |
||
− | |||
− | with the change you suggested |
||
− | |||
− | bphelan--AT--mathworks.co.uk |
||
− | , April 25, 2003 3:19 |
||
− | ---- |
||
− | Hello! |
||
− | |||
− | OK, I've put my version, [/scripts/script.php?script_id=628 vimscript#628]. It now handles both |
||
− | expandtab on and off cases. Enjoy! |
||
− | |||
− | cec--AT--NgrOyphSon.gPsfAc.nMasa.gov |
||
− | , April 25, 2003 14:11 |
||
---- |
---- |
||
+ | There are now two scripts for this: |
||
− | /me claps -- nothing like a little good competition |
||
+ | *{{script|id=627}} |
||
+ | *{{script|id=628}} |
||
− | '''Anonymous''' |
||
− | , April 25, 2003 14:41 |
||
---- |
---- |
||
− | <!-- parsed by vimtips.py in 0.461881 seconds--> |
Revision as of 08:44, 29 September 2008
Tip 460 Printable Monobook Previous Next
created April 21, 2003 · complexity basic · author Robert (MetaCosm) · version 5.7
When browsing the jEdit screenshots page, I saw a feature I wanted and didn't have in Vim. It was a vertical line showing the Tab characters.
if (this) { | if (that) { | | do stuff; | } }
I was wondering how to do this in Vim. Turns out it is simple.
:set list :set listchars=tab:\|\<Space>
References
Comments
In order to tweak the colors
highlight SpecialKey guifg=<color> ctermfg=<color>
Here's a function+command to facilitate use:
Usage: :SeeTab (toggles between normal and bar'd tabbing styles)
" SeeTab: toggles between showing tabs and using standard listchars fu! SeeTab() if !exists("g:SeeTabEnabled") let g:SeeTabEnabled = 1 let g:SeeTab_list = &list let g:SeeTab_listchars = &listchars let regA = @a redir @a hi SpecialKey redir END let g:SeeTabSpecialKey = @a let @a = regA silent! hi SpecialKey guifg=black guibg=magenta ctermfg=black ctermbg=magenta set list set listchars=tab:\|\ else let &list = g:SeeTab_list let &listchars = &listchars silent! exe "hi ".substitute(g:SeeTabSpecialKey,'xxx','','e') unlet g:SeeTabEnabled g:SeeTab_list g:SeeTab_listchars endif endfunc com! -nargs=0 SeeTab :call SeeTab()
Use syntax highlighting when expand tabs are on. Note the use of &sw to get the current shiftwidth for the expanded tabs.
fu! SeeTab() if !exists("g:SeeTabEnabled") let g:SeeTabEnabled = 0 end if g:SeeTabEnabled==0 syn match leadspace /^\s\+/ contains=syntab exe "syn match syntab /\\s\\{" . &sw . "}/hs=s,he=s+1 contained" hi syntab guibg=Grey let g:SeeTabEnabled=1 else syn clear leadspace syn clear syntab let g:SeeTabEnabled=0 end endfunc com! -nargs=0 SeeTab :call SeeTab()
One correction: expand tabs setting expands tabs according to the tabstop setting not shiftwidth - so in the SeeTab() function, replace &sw by &ts
There are now two scripts for this: