Skip to content

Instantly share code, notes, and snippets.

@voyeg3r
Last active February 12, 2018 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voyeg3r/2ad467f379548e3f13f0229a88bcffe9 to your computer and use it in GitHub Desktop.
Save voyeg3r/2ad467f379548e3f13f0229a88bcffe9 to your computer and use it in GitHub Desktop.

Reverse paragraphs order using [n]vim

Let's say you have a file with these lines and whant to reverse its paragraphs order. Using our belove [n]vim you can just execute

I have added the line numbers but you can ajust the numbers accordingly

1   \begin{rSubsection}{Example 1}{}{Redacted}{}
2   \item Stuff I did
3   \item Also did other things
4   \end{rSubsection}
5   
6   \begin{rSubsection}{Example 2}{}{Redacted}{}
7   \item Stuff I did
8   \item Also did other things
9   \end{rSubsection}
10  
11  \begin{rSubsection}{Example 3}{}{Redacted}{}
12  \item Stuff I did
13  \item Also did other things
14  \end{rSubsection}
15  
16  \begin{rSubsection}{Example 4}{}{Redacted}{}
17  \item Stuff I did
18  \item Also did other things
19  \end{rSubsection}

My solution

:$pu _ | 16,20m0 | 16,20m5 | 16,20m10

Other way of solving this puzzle

:$pu _ | normal gg
:16,$m.-1 | normal j
@@
@@

The final result

\begin{rSubsection}{Example 4}{}{Redacted}{}
\item Stuff I did
\item Also did other things
\end{rSubsection}

\begin{rSubsection}{Example 3}{}{Redacted}{}
\item Stuff I did
\item Also did other things
\end{rSubsection}

\begin{rSubsection}{Example 2}{}{Redacted}{}
\item Stuff I did
\item Also did other things
\end{rSubsection}

\begin{rSubsection}{Example 1}{}{Redacted}{}
\item Stuff I did
\item Also did other things
\end{rSubsection}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment