Am 25.08.2012 11:07, schrieb Santosh Kumar:
> By default I have textwidth set to 78:
> set textwidth=78
>
> By this setting if I type more than 78 characters in a line, those
> will be moved to next line.
> I want a mapping that will toogle that textwidth to 0 (or say disable
> textwidth), so that I can type long sentences in a single line.
>
> Currently I have this mapping:
> nnoremap <silent> <leader>tw :exe "set textwidth=" . (&tw ? 0 : 78)<cr>
This one is more verbose, without visual clutter:
:nn <expr> <Leader>tw printf(":setl tw=%d<CR>", &tw==0 ? 78 : 0)
> This does the work but I don't get notified if the work has been done.
> All I want is along with toggling the setting I should be notified
> (i.e. if textwidth is zero then show textwidth=0 at statusline).
An example how to play with the statusline:
:h 'stl
" standard statusline
" set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
set statusline=%<%f\ %h%m%r%{TwLeft()}%=%-14.(%l,%c%V%)\ %P
" remaining textwidth
func! TwLeft()
let ioff = mode()==#"i" ? 1 : 0
if &tw == 0 || virtcol(".") > &tw + ioff
return ""
else
let left = &tw + ioff - virtcol(".")
return printf('[%d %s left]', left, left==1 ? "char" : "chars")
endif
endfunc
--
Andy
--
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
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment