Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
PORTFMT(1)		FreeBSD	General	Commands Manual		    PORTFMT(1)

NAME
     portfmt --	format FreeBSD Ports Collection	Makefiles

SYNOPSIS
     portfmt [-Dditu] [-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	     Output a unified diff from	the original to	the formatted version.

     -d	     Dump the list of recognized tokens	to stdout.  This is only use-
	     ful for debugging purposes.  If this flag is specified -i is ig-
	     nored.

     -i	     Format Makefile in-place instead of writing the result to stdout.

     -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 variables
	     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>

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 pos-
	     sible 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.0			 June 4, 2020			  FreeBSD 13.0

NAME | SYNOPSIS | DESCRIPTION | EDITOR INTEGRATION | EXIT STATUS | EXAMPLES | SEE ALSO | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=portfmt&sektion=1&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help