Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
Put boxes around comments in code
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
Put boxes around comments in code
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{review}} {{TipImported |id=998 |previous=997 |next=999 |created=September 23, 2005 |complexity=basic |author=Narayanan Iyer |version=5.7 |rating=16/8 |category1= |category2= }} Programmers sometimes try to put a box around comments in code, especially function headers. It could be argued that using boxes is bad practice because it requires more editing when you change comments. However, here is a procedure to box comments. First you need to install the boxes utility from http://boxes.thomasjensen.com/ You can get the source and compile it yourself or there is binary version available for almost all architectures. Once you have this, the rest is pretty simple. Select the text you want to "boxify" and press F2. Add the following mapping to your vimrc: <pre> vmap <F2> "ad:enew<CR>"ap:w! c:\selected.txt<CR>:bde<CR><Esc>:r! boxes -dshell c:\selected.txt<CR><Esc> </pre> This is for Windows and you should have boxes in your path (or put it in your winnt directory). Linux users can change this as required. For example like this: <pre> vmap <F2> !boxes <CR> </pre> And if one wishes to use a fixed width for the box, add this option to the boxes command: <pre> vmap <F2> !boxes -s 80 <CR> </pre> Example (text to boxify): <pre> Subroutine :TestFC Description :Runs flight controller test serially and generates a test report Argument :$_[0] flight speed kmph, $_[1] wind drag Returns :File handle to test result </pre> Result from applying boxes: <pre> ########################################################## # Subroutine :TestFC # # Description :Runs flight controller test serially and # # generates a test report # # Argument :$_[0] flight speed kmph, $_[1] wind drag # # Returns :File handle to test result # ########################################################## </pre> See: *http://www.vmunix.com/vim/util.html *http://boxes.thomasjensen.com/ Boxes has a configfile where you can specify the kind of boxes you want. ==Comments==
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Navigation
(
view source
)
Template:Review
(
view source
)
Template:TipImported
(
view source
)
Follow on IG
TikTok
Join Fan Lab