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 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).
> 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 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).
>> 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 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).
> --
> 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
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:
'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
> Can't we create a function named Toogletw() and call it on this mapping?
I hadn't read "status-line"; my code prints the width in the command-line.
If you want the value of "textwidth" to be mentioned in the status line, then
change the "statusline" option, and let your mapping simply change that value;
the change will be automatically reflected in the status line. The simpler
solution is (see ":help statusline"):
setlocal statusline=%!&tw
Of course the problem then is what happens if you don't have a status-line?
> > Can't we create a function named Toogletw() and call it on this mapping?
> I hadn't read "status-line"; my code prints the width in the command-line.
> If you want the value of "textwidth" to be mentioned in the status line, then
> change the "statusline" option, and let your mapping simply change that value;
> the change will be automatically reflected in the status line. The simpler
> solution is (see ":help statusline"):
> setlocal statusline=%!&tw
> Of course the problem then is what happens if you don't have a status-line?
You could put a textwidth indication in the ruler, which doesn't
take as much screen space as the statusline, but 'rulerformat'
doesn't give you as much space for customization.
On Aug 25, 2:07 am, Santosh Kumar <sntshkm...@gmail.com> wrote:
> 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 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 colorcolumn
Add this to your .vimrc:
set colorcolumn=+1
hi ColorColumn NONE ctermbg=Cyan
When textwidth=0 there is no colorcolumn,
otherwise it is drawn just after the textwidth.
> 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 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 colorcolumn
Add this to your .vimrc:
set colorcolumn=+1
hi ColorColumn NONE ctermbg=Cyan
When textwidth=0 there is no colorcolumn,
otherwise it is drawn just after the textwidth.
> 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 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