On Sat, Aug 25, 2012 at 02:37:43PM +0530, Santosh Kumar wrote:
> [snip]
>
> Currently I have this mapping:
> nnoremap <silent> <leader>tw :exe "set textwidth=" . (&tw ? 0 : 78)<cr>
>
> 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).

:help let-option comes useful in these cases. For example:

    :nnoremap tw :let &textwidth = (&textwidth ? 0 : 78)<CR>:set textwidth?<CR>

It's a bit shorter and IMHO easier to read.

'formatoption' l (:help fo-table) might also be useful:

    l   Long lines are not broken in insert mode: When a line was
        longer than 'textwidth' when the insert command started,
        Vim does not automatically format it.

Regards,
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

Attachment: pgpnUtKtEkTg5.pgp
Description: PGP signature

Reply via email to