I found this answer and I applied it but this is the result.
This is my code.
\documentclass[conference]{IEEEtran}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{algorithm}
\PassOptionsToPackage{noend}{algpseudocode}% comment out if want end's to show
\usepackage{algpseudocode}
\makeatletter
% start with some helper code
% This is the vertical rule that is inserted
\newcommand*{\algrule}[1][\algorithmicindent]{\makebox[#1][l]{\hspace*{.5em}\vrule height .75\baselineskip depth .25\baselineskip}}%
\newcount\ALG@printindent@tempcnta
\def\ALG@printindent{%
\ifnum \theALG@nested>0% is there anything to print
\ifx\ALG@text\ALG@x@notext% is this an end group without any text?
% do nothing
\addvspace{-3pt}% FUDGE for cases where no text is shown, to make the rules line up
\else
\unskip
% draw a rule for each indent level
\ALG@printindent@tempcnta=1
\loop
\algrule[\csname ALG@ind@\the\ALG@printindent@tempcnta\endcsname]%
\advance \ALG@printindent@tempcnta 1
\ifnum \ALG@printindent@tempcnta<\numexpr\theALG@nested+1\relax% can't do <=, so add one to RHS and use < instead
\repeat
\fi
\fi
}%
\usepackage{etoolbox}
% the following line injects our new indent handling code in place of the default spacing
\patchcmd{\ALG@doentity}{\noindent\hskip\ALG@tlm}{\ALG@printindent}{}{\errmessage{failed to patch}}
\makeatother
% end vertical rule patch for algorithmicx
\makeatother
\begin{document}
\IEEEpeerreviewmaketitle
\begin{algorithm}
\caption{Arbitrary Algorithm}\label{IS2OSLS}
\begin{algorithmic}[1]
\Require A matrix $\mathbf{A}$ of size $m\times n$.
\Ensure Something.
\For{$i$ in $m$}
\For{$j$ in $n$}
\If{$i=j$}
\State Select a random action
\Else
\If{$i=j+1$}
\State Stay silent
\Else
\State Break
\EndIf
\EndIf
\EndFor
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}
I wold like to have vertical lines that start just after the first letter of the keyword, i.e., for the keyword for the vertical line should start after f, etc. In the figure above, the vertical lines start after the o not the f. Also I need the pseudo code without the end keyword as shown.
Thank you.
EDIT
I can change \hspace*{.5em} to \hspace*{.1em} in order to move the vertical line a little to the left. This is solved. But why do the lines overlaps at the end of the algorithm? (If I add the end keywords the problem is solved.)


\color{whatever}just before\vrule. – egreg Feb 15 '16 at 00:07setspace– egreg Mar 29 '16 at 19:28setspacepackage. But, when I remove this line\usepackage[lite,subscriptcorrection,slantedGreek,nofontinfo]{mtpro2}, there is no spaces and the vertical rules are fine. Do you know how can I fix this? – Chiba Mar 29 '16 at 19:39\usepackage{algpseudocode}one has to use\usepackage[noend]{algpseudocode}which makes the algorithm not look as good since missing all theend ifand otherend. It will be great if this worked withendsupport. – Nasser Jun 12 '20 at 08:34noend. https://tex.stackexchange.com/questions/52473/is-it-possible-to-have-connecting-loop-lines-like-algorithm2e-in-algorithmic . Thanks. – Nasser Jun 12 '20 at 08:43