FreeBSD Manual Pages
PORTFMT(1) General Commands Manual PORTFMT(1) NAME portfmt -- format FreeBSD Ports Collection Makefiles SYNOPSIS portfmt [-D[context]] [-ditu] [-w wrapcol] [Makefile] DESCRIPTION portfmt is a tool for formatting FreeBSD Ports Collection Makefiles. If the optional Makefile argument is not given, the Makefile will be read from stdin. This can be useful for editor integration where you might want to only format portions of your Makefile. The following options are available: -D[context] Output a unified diff from the original to the formatted ver- sion. This can optionally be followed by the number of context lines. It defaults to 3 lines of context. For full context use 0. -d Dump the AST to stdout. This is only useful for debugging pur- poses. If this flag is specified -i is ignored. -i Format Makefile in-place instead of writing the result to std- out. -t Format and reindent target commands. -u Leave variables unsorted. -U Always sort variables. -w wrapcol Sets the wrapping column to wrapcol (default: 80). This is a goal not a hard value. It will be ignored for several vari- ables like COMMENT, DISTFILES, MASTER_SITES, etc. With a value of -1 it is ignored for all variables. Variables with wrapped tokens over multiple lines will be concatenated onto a single line. EDITOR INTEGRATION You can integrate Portfmt into your editor to conveniently run it only on parts of the port, e.g., to reformat USES after adding a new item to it. Emacs Add this to ~/.emacs.d/init.el to format the current region with C-c p: (defun portfmt (&optional b e) "PORTFMT(1) on region" (interactive "r") (shell-command-on-region b e "portfmt " (current-buffer) t "*portfmt errors*" t)) (with-eval-after-load 'make-mode (define-key makefile-bsdmake-mode-map (kbd "C-c p") 'portfmt)) Kakoune Add this to ~/.config/kak/kakrc for filtering the current selection through portfmt with ,1: map global user 1 '|portfmt<ret>;' \ -docstring "portfmt on selection" Vim Add this to ~/.vimrc for filtering the current selection through portfmt with \1: xnoremap <leader>1 <esc>:'<,'>!portfmt<CR> ENVIRONMENT The following environment variables affect the execution of portfmt: CLICOLOR_FORCE If defined portfmt will output text with ANSI colors even when stdout is not a tty or NO_COLOR is set. NO_COLOR If defined colors will be disabled. EXIT STATUS portfmt will exit with one of the following values: 0 Success. 1 An error occurred. 2 There were changes when compared to the original file. Only possible with -D. EXAMPLES In-place format /usr/ports/audio/sndio/Makefile: portfmt -i /usr/ports/audio/sndio/Makefile SEE ALSO ports(7) AUTHORS Tobias Kortkamp <tobik@FreeBSD.org> FreeBSD 13.2 September 19, 2021 PORTFMT(1)
NAME | SYNOPSIS | DESCRIPTION | EDITOR INTEGRATION | ENVIRONMENT | EXIT STATUS | EXAMPLES | SEE ALSO | AUTHORS
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=portfmt&sektion=1&manpath=FreeBSD+14.2-RELEASE+and+Ports>