Preferred method for inline code samples

AFIK this is an area, where you cannot use Pygments.

The simplest way to achieve it from a "typing" point of view is to use a "short verbatim".

\documentclass{article}
\usepackage{fancyvrb}
\DefineShortVerb{\|}
\begin{document}
This is some inline code |for i=1;i<20;i++| and more \ldots
\end{document}

The package fancyvrb offers a number of customizations as well.


You can do it with minted if you are willing to patch it:

\documentclass{minimal}
\usepackage{ifplatform}
\ifwindows\else
\newcommand*{\TestAppExists}[1]{% there is no `which -s` on Linux
  \immediate\write18{which -- '#1' > /dev/null && touch -- '\jobname.aex'}%
  \IfFileExists{\jobname.aex}{%
    \AppExiststrue
    \DeleteFile{\jobname.aex}%
  }{%
    \AppExistsfalse
  }
}
\fi
\usepackage{minted}
\makeatletter
% avoid space tokens since we're in horizontal mode
\renewcommand\mint[3][]{%
  \DefineShortVerb{#3}%
  \minted@resetoptions
  \setkeys{minted@opt}{#1}%
  \SaveVerb[aftersave={%
    \UndefineShortVerb{#3}%
    \minted@savecode{\FV@SV@minted@verb}%
    \minted@pygmentize{#2}%
    \DeleteFile{\jobname.pyg}}]{minted@verb}#3}
\renewcommand\minted@savecode[1]{%
  \immediate\openout\minted@code\jobname.pyg\relax
  \immediate\write\minted@code{#1}%
  \immediate\closeout\minted@code}
\renewcommand\minted@pygmentize[2][\jobname.pyg]{%
  \def\minted@cmd{pygmentize -l #2 -f latex -F tokenmerge
    \minted@opt{gobble} \minted@opt{texcl} \minted@opt{mathescape}
    \minted@opt{linenos} -P "verboptions=\minted@opt{extra}"
    -o \jobname.out.pyg #1}%
  \immediate\write18{\minted@cmd}%
  \ifthenelse{\equal{\minted@opt@bgcolor}{}}%
   {}%
   {\begin{minted@colorbg}{\minted@opt@bgcolor}}%
  \input{\jobname.out.pyg}%
  \ifthenelse{\equal{\minted@opt@bgcolor}{}}%
   {}%
   {\end{minted@colorbg}}%
  \DeleteFile{\jobname.out.pyg}}
\makeatother
\RecustomVerbatimEnvironment{Verbatim}{BVerbatim}{}
\begin{document}
This is some inline code \mint{c++}|for i=1;i<20;i++| and more \ldots
\end{document}

Just for reference, see also issue 15 on the minted project page, and in particular a temporary fix that I posted there (but which probably does much the same as Philipp’s hack anyway).

In summary, this is on the “to do” list but not yet officially supported since I’m currently busy and don’t have time to work on minted.