Pentadactyl allows you to use an external text editor for <textarea> and <input type="text"> elements on websites. I use GVim for this. This functionality is very useful but drives me to a question. I frequently want to wrap the text after editing, so my workflow is as follows:
- CTRL+I to launch GVim
- Use
:set tw=72 - Perform my text manipulation
- Use
gqto re-wrap areas that require it :wq
I would like to skip step #2 without affecting other editing in [G]Vim (i.e. I don’t want to outright set tw=72 in .[g]vimrc for all files). What is the best way to :set tw=72 in this specific circumstance on Linux for example, where Pentadactyl always launches $EDITOR on /tmp/pentadactyl.txt?
Add an
autocmdfor this file to your .vimrc:This adds a hook that automatically does
setlocal tw=72whenever you’re starting to edit a buffer after reading the given filename.See
:help autocmdand:help autocmd-eventsfor more information.Similarly, if your step #4 is predictable, i.e. you’re always reformatting the entire file, you could add an
autocmdforBufWrite.