I am trying to perform a multiple line search and replace while retaining the indent, leading space, in the code I am working with. Below is a text sample which approximates the situation. The problem I'm having is preserving the white space. I'm hoping for a non-plugin, plain jane VIM solution via :%s/ ......
VIM 7.2 on Windows 7
autoindent is on
expandtab is on
Starting with:
apples,
banannas,
cherries,
plums
peas,
green beans,
corn,
squash
apples,
banannas,
cherries,
plums
I would like to add "pears,", without the double quotes and following the "cherries," line in the list. The desired outcome is:
apples,
banannas,
cherries,
pears,
plums
peas,
green beans,
corn,
squash
apples,
banannas,
cherries,
pears,
plums
Trying :%s/cherries,/&\rpears,/g yields ...
apples,
banannas,
cherries,
pears,
plums
peas,
green beans,
corn,
squash
apples,
banannas,
cherries,
pears,
plums
Trying :%s/cherries,_s.\s*/&pears,\r/g yields ...
apples,
banannas,
cherries,
pears,
plums
peas,
green beans,
corn,
squash
apples,
banannas,
cherries,
pears,
plums
Thank you!
You could take advantage of :g and auto-indentation with normal o:
:g/cherries,/normal opears,
Try to extract the whitespace just before the word and insert it in the replacement part (\1).
NOTE that I use \v at the beginning but it does not match anything, it is to make the regular expression very magic and avoid to escape many characters, like parentheses.
:%s/\v(\s*)cherries,/&\r\1pears,/g
It yields:
apples,
banannas,
cherries,
pears,
plums
peas,
green beans,
corn,
squash
apples,
banannas,
cherries,
pears,
plums
Related
I'm trying to find a value on a table, and getting an index on the same row. Something like this:
I have a table like this:
name id1 id2 id3
Jorg pear -- apple
Anna lemon banana --
and on another page I have this:
pear
apple
lemon
banana
And I want the match like this
pear jorg
apple jorg
lemon anna
banana anna
Does anyone know a quick way to do it? I tried with match to find the row and then triying to find the cell but I wasn't able to do it.
Use AGGREGATE not MATCH:
=INDEX(A:A,AGGREGATE(15,7,ROW($B$2:$D$3)/($B$2:$D$3=F2),1))
I have this vague idea that I should be able to use the above formulas to compile a list of combined values. There may be a much easier way to do this but my brain has started down this track so I thought it best to float it out there and see what it is that I get back.
I've made an example wherein I have 4 donut shops, they each have more than one location and I would like to perform two functions: One would (using the small function and the countif value) go through and return each value in a new cell in the same row, Second would be using the countif and small functions to concatenate each value into a orderly string.
My thought with this is I will then be able to use conditional formatting on each of the individual listings in a Search function (or index match) to tell me which names from database one (as associated with Company A) lineup with names as listed in database two (as associated with Company A). I know I'm referencing an example set and the corresponding application to an actual data set.
Count Towns
Dunkin Donuts Norwell Dunkin Donuts 6
Honey Dew Hanover Honey Dew 3
Dunkin Donuts Springfield Beard Papa 2
Cronut Walnut Creek Cronut 2
Beard Papa Culver City
Cronut Santa Monica
Dunkin Donuts Summerville
Honey Dew Charlestown
Beard Papa Oakland
Dunkin Donuts Dorchester
Dunkin Donuts Jamaica Plain
Dunkin Donuts San Francisco
Honey Dew Agoura
i need help on excel
i have table looking like this(it's an example):
cheese tomato chocolate cream
Pizza 2 3
cake 1 1
And i want to have names of ingredients for each plates from the highest one to the lowest if we consider that the numbers are the lead time for each ingredient and if the lead time is the same i don't want to have the same name in both cells.
like this:
Ingredient 1 Ingredient 2 ingredient3
pizza tomato cheese nothing
cake chocolate cream
thank you, please help :)
Try the formula as shown in the image,
=IFERROR(INDEX($B$1:$E$1,MATCH(LARGE($B2:$E2,COLUMN(A1)),$B2:$E2,0)),"nothing")
Am not sure how you want to represent data if the lead time is same. The formula currently shows chocolate twice. You may have to alter it according to your needs. Drag the formula to right and then down for the complete range.
I'm a bit of an Excel novice. I have searched but couldn't find an answer. Based on input from Columns A and B:
Column A
Gonnella Italian Soft Rolls
Gonnella Sub Buns
Healthy Life 100% Whole Wheat Soft Style Sandwich Buns
Healthy Life Wheat Hot Dog Buns
King's Hawaiian Bread Round Original Hawaiian Sweet
King's Hawaiian Original Hawaiian Sweet Hamburger Buns
Column B
Gonnella
Healthy Life
King's Hawaiian
Wheat
Italian
Sandwich Buns
Hamburger Buns
Hot Dog Buns
I am looking for output in Column C like so:
Gonnella|Italian
Gonnella
Healthy Life|Wheat|Sandwich Buns
Healthy Life|Wheat|Hot Dog Buns
etc...
I want to search for keywords in Column A using the keywords that are in Column B and have the results in Column C (as shown above) separated by | between each keyword.
I know I can use =IFERROR(LOOKUP(2^15,SEARCH(B$1:B$10,A1),B$1:B$10),"") but it only gives me one result.
Is it possible to get multiple results into one cell using the search and lookup function (or any other function)?
Yes, for example with your formula and &"|"& and then another formula (without = at the start of that) - all in the one cell.
If the formulae either side of the pipe are the same then so should the results be, or Excel would be showing inconsistency.
The & is a short way of concatenating and with a pipe between the two formulae the results will always be strings.
The separator is more commonly a comma and hence will usually include a space: &", "&
I need assistance in seeing if there’s a formula to the below excel dilemma:
(Note - dash lines are used as separators indicating different column)
Currently I have a spread sheet with the below data: 2 columns (A--B)
Abby -- apple
Abby -- orange
Abby -- lime
Bob -- orange
Bob -- apple
Carol-- lime
Carol-- orange
David-- apple
Is there a formula that tells Excel to pick up identical text in Column A and consolidate the respective Column B items into one Cell in Column C? : please find below the end result that I’m after:
Abby -- apple ---- apple orange lime
Abby -- orange
Abby -- lime
Bob -- orange ---- orange apple
Bob -- apple
Carol-- lime ---- lime orange
Carol-- orange
David-- apple ---- apple
Thank you in advance.
Regards,
Kit
You may be able to modify the answer to this question to fit your needs. It's more complex than what you need since you are only matching on a single column instead of two or more, but the underlying concept is actually the same.