Frequently, e.g. when I write Latex code, I come across the task to rearrange items of a list that are separated by commas. This is quickly done if both items are not at the at the beginning or the end of the list. But if they are at the margins, one has to take extra care of the separating comma.
As an example consider
\cite{GirR84, Tar00, Tem77}.
Is there a smart way in vim to put, e.g., the last item to the front or to the middle position?
Approach: This can be achieved with the help of join() method of String as follows. Get the List of String. Form a comma separated String from the List of String using join() method by passing comma ', ' and the list as parameters. Print the String.
For example, C{:,1} is a comma-separated list if C has more than one row. A comma-separated list is produced for a structure array when you access one field from multiple structure elements at a time.
Type the formula =CONCATENATE(TRANSPOSE(A1:A7)&",") in a blank cell adjacent to the list's initial data, for example, cell C1. (The column A1:A7 will be converted to a comma-serrated list, and the separator "," will be used to separate the list.)
I actually made a plugin to deal with a similar situation called argumentative.vim. (Sorry for the plug.)
Argumentative.vim provides the following mappings:
[,
and ],
motions which will go to the previous or next argument<,
and >,
to shift an argument left or righti,
and a,
argument text objects. e.g. da,
, ci,
or yi,
So with this plugin you move to the argument in question and then do a <,
or >,
as many times as needed. It can also take a count e.g. 2>,
.
If you have Tim Pope's excellent repeat.vim plugin installed <,
and >,
become repeatable with the .
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With