Peter Stuifzand

Write Twitter drafts in Vim

Not everyone writes drafts for his Twitter posts. It seems silly even to do this.

But for the people who don’t think writing drafts is silly (and use Vim), I wrote a few lines of Vim script that will help them keep their lines just short enough.

Put these lines in your .vimrc file and start writing. You should change the filename to the name of the file that you write your drafts in. As usual, this code comes without any warranty.

" Call the function that will highlight the lines that are too long.
au BufNewFile,BufRead /home/peter/doc/twitter.txt call TwitterLineLengths()

highlight OverLength ctermbg=darkred ctermfg=white guibg=#FFD9D9

function! TwitterLineLengths()
    3match OverLength /\%141v.\+/
endfunction

Code based on code from Stackoverflow.

© 2023 Peter Stuifzand