How to get all distinct words within a set of lines? Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Check if value matches any regex in a listHow to surround all headlines with empty new lines in a markdown file?How to replace content between two patterns from the file?Why does append(…, readfile()) add a zero when run using Ctrl-R?Get list of lines that begin with a patternHow to anchor matchlist after searchpos?Break-down long strings and search/replace individual wordsAre script local functions (s:funcName()) unit testable?Why does `:call f(…)` do nothing while mapping it to a binding works?Add conceal in function

Plotting a Maclaurin series

Random body shuffle every night—can we still function?

Does a random sequence of vectors span a Hilbert space?

Is the Mordenkainen's Sword spell underpowered?

Flight departed from the gate 5 min before scheduled departure time. Refund options

Can two people see the same photon?

Why complex landing gears are used instead of simple, reliable and light weight muscle wire or shape memory alloys?

Improvising over quartal voicings

Are there any irrational/transcendental numbers for which the distribution of decimal digits is not uniform?

How does TikZ render an arc?

How do you write "wild blueberries flavored"?

Should man-made satellites feature an intelligent inverted "cow catcher"?

Why is there so little support for joining EFTA in the British parliament?

How to infer difference of population proportion between two groups when proportion is small?

When does a function NOT have an antiderivative?

Fit odd number of triplets in a measure?

How could a hydrazine and N2O4 cloud (or it's reactants) show up in weather radar?

How to make an animal which can only breed for a certain number of generations?

Any stored/leased 737s that could substitute for grounded MAXs?

Is this Kuo-toa homebrew race balanced?

What is a more techy Technical Writer job title that isn't cutesy or confusing?

Do i imagine the linear (straight line) homotopy in a correct way?

One-one communication

Can gravitational waves pass through a black hole?



How to get all distinct words within a set of lines?



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Check if value matches any regex in a listHow to surround all headlines with empty new lines in a markdown file?How to replace content between two patterns from the file?Why does append(…, readfile()) add a zero when run using Ctrl-R?Get list of lines that begin with a patternHow to anchor matchlist after searchpos?Break-down long strings and search/replace individual wordsAre script local functions (s:funcName()) unit testable?Why does `:call f(…)` do nothing while mapping it to a binding works?Add conceal in function










4















I would like to extract a list of distinct words from a set of lines. Is there a way of doing this ?



Say for example I have lines that look like this:



[
[(isPhysicallySettledFxFwd, NO,"Y"),(isPhysicallySettledFxFwd,isPhysicallySettledFxSwap,"N")],
[(isPhysicallySettledFxSwap,NO,"Y"),(isPhysicallySettledFxSwap, isPhysicallySettledCommodity,"Y")],
[(isPhysicallySettledCommodity,NO,"Y"),(isPhysicallySettledCommodity,YES,"Y")]
]


Then i would get a list of distinct words, looking this:



isPhysicallySettledFxFwd
isPhysicallySettledFxSwap
isPhysicallySettledCommodity
NO
YES
Y
N
(
)
"
[
]
,


I am not sure how to even start, apart from copying the lines to Excel and doing lots of manipulations...










share|improve this question







New contributor




user3203476 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    4















    I would like to extract a list of distinct words from a set of lines. Is there a way of doing this ?



    Say for example I have lines that look like this:



    [
    [(isPhysicallySettledFxFwd, NO,"Y"),(isPhysicallySettledFxFwd,isPhysicallySettledFxSwap,"N")],
    [(isPhysicallySettledFxSwap,NO,"Y"),(isPhysicallySettledFxSwap, isPhysicallySettledCommodity,"Y")],
    [(isPhysicallySettledCommodity,NO,"Y"),(isPhysicallySettledCommodity,YES,"Y")]
    ]


    Then i would get a list of distinct words, looking this:



    isPhysicallySettledFxFwd
    isPhysicallySettledFxSwap
    isPhysicallySettledCommodity
    NO
    YES
    Y
    N
    (
    )
    "
    [
    ]
    ,


    I am not sure how to even start, apart from copying the lines to Excel and doing lots of manipulations...










    share|improve this question







    New contributor




    user3203476 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      4












      4








      4








      I would like to extract a list of distinct words from a set of lines. Is there a way of doing this ?



      Say for example I have lines that look like this:



      [
      [(isPhysicallySettledFxFwd, NO,"Y"),(isPhysicallySettledFxFwd,isPhysicallySettledFxSwap,"N")],
      [(isPhysicallySettledFxSwap,NO,"Y"),(isPhysicallySettledFxSwap, isPhysicallySettledCommodity,"Y")],
      [(isPhysicallySettledCommodity,NO,"Y"),(isPhysicallySettledCommodity,YES,"Y")]
      ]


      Then i would get a list of distinct words, looking this:



      isPhysicallySettledFxFwd
      isPhysicallySettledFxSwap
      isPhysicallySettledCommodity
      NO
      YES
      Y
      N
      (
      )
      "
      [
      ]
      ,


      I am not sure how to even start, apart from copying the lines to Excel and doing lots of manipulations...










      share|improve this question







      New contributor




      user3203476 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I would like to extract a list of distinct words from a set of lines. Is there a way of doing this ?



      Say for example I have lines that look like this:



      [
      [(isPhysicallySettledFxFwd, NO,"Y"),(isPhysicallySettledFxFwd,isPhysicallySettledFxSwap,"N")],
      [(isPhysicallySettledFxSwap,NO,"Y"),(isPhysicallySettledFxSwap, isPhysicallySettledCommodity,"Y")],
      [(isPhysicallySettledCommodity,NO,"Y"),(isPhysicallySettledCommodity,YES,"Y")]
      ]


      Then i would get a list of distinct words, looking this:



      isPhysicallySettledFxFwd
      isPhysicallySettledFxSwap
      isPhysicallySettledCommodity
      NO
      YES
      Y
      N
      (
      )
      "
      [
      ]
      ,


      I am not sure how to even start, apart from copying the lines to Excel and doing lots of manipulations...







      regular-expression functions vi-words list






      share|improve this question







      New contributor




      user3203476 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      user3203476 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      user3203476 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      user3203476user3203476

      1233




      1233




      New contributor




      user3203476 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      user3203476 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      user3203476 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          3 Answers
          3






          active

          oldest

          votes


















          3














          You can do something like this:



          :let a=[]
          :%s/w+/=add(a, submatch(0))/gn
          :new
          :put =uniq(sort(a))


          This will first declare a list a to work with. Then we run a :%s command, to capture all word-characters (w+) and act on all matches (g flag of the :s command), but won't actually replace (n flag). We use a sub-replace-expression(=) in the replacement part, to store the captured submatch in list a.



          And finally, we create a new window, and put the unique and sorted (uniq) content of list a into it.



          You can get a lot more sophisticated, like only capturing certain words, or counting the numbers, but this shows how flexible the :s command is.






          share|improve this answer























          • how wonderful ! thank you !!

            – user3203476
            2 days ago


















          2














          Maybe this:



          :%s/W/rr/g
          :sort u
          :g/^s*$/d


          The first puts a line break before and after each non-word character.



          The second command sorts the entire file with the option "unique", so all duplicate lines are removed.



          The third command deletes all lines that are empty or only contain whitespaces.






          share|improve this answer






























            1














            You can use grep with the --only-matching/-o flag to accomplish this:



            :%!grep -o 'w+|W' | sort -u





            share|improve this answer























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "599"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );






              user3203476 is a new contributor. Be nice, and check out our Code of Conduct.









              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f19653%2fhow-to-get-all-distinct-words-within-a-set-of-lines%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              You can do something like this:



              :let a=[]
              :%s/w+/=add(a, submatch(0))/gn
              :new
              :put =uniq(sort(a))


              This will first declare a list a to work with. Then we run a :%s command, to capture all word-characters (w+) and act on all matches (g flag of the :s command), but won't actually replace (n flag). We use a sub-replace-expression(=) in the replacement part, to store the captured submatch in list a.



              And finally, we create a new window, and put the unique and sorted (uniq) content of list a into it.



              You can get a lot more sophisticated, like only capturing certain words, or counting the numbers, but this shows how flexible the :s command is.






              share|improve this answer























              • how wonderful ! thank you !!

                – user3203476
                2 days ago















              3














              You can do something like this:



              :let a=[]
              :%s/w+/=add(a, submatch(0))/gn
              :new
              :put =uniq(sort(a))


              This will first declare a list a to work with. Then we run a :%s command, to capture all word-characters (w+) and act on all matches (g flag of the :s command), but won't actually replace (n flag). We use a sub-replace-expression(=) in the replacement part, to store the captured submatch in list a.



              And finally, we create a new window, and put the unique and sorted (uniq) content of list a into it.



              You can get a lot more sophisticated, like only capturing certain words, or counting the numbers, but this shows how flexible the :s command is.






              share|improve this answer























              • how wonderful ! thank you !!

                – user3203476
                2 days ago













              3












              3








              3







              You can do something like this:



              :let a=[]
              :%s/w+/=add(a, submatch(0))/gn
              :new
              :put =uniq(sort(a))


              This will first declare a list a to work with. Then we run a :%s command, to capture all word-characters (w+) and act on all matches (g flag of the :s command), but won't actually replace (n flag). We use a sub-replace-expression(=) in the replacement part, to store the captured submatch in list a.



              And finally, we create a new window, and put the unique and sorted (uniq) content of list a into it.



              You can get a lot more sophisticated, like only capturing certain words, or counting the numbers, but this shows how flexible the :s command is.






              share|improve this answer













              You can do something like this:



              :let a=[]
              :%s/w+/=add(a, submatch(0))/gn
              :new
              :put =uniq(sort(a))


              This will first declare a list a to work with. Then we run a :%s command, to capture all word-characters (w+) and act on all matches (g flag of the :s command), but won't actually replace (n flag). We use a sub-replace-expression(=) in the replacement part, to store the captured submatch in list a.



              And finally, we create a new window, and put the unique and sorted (uniq) content of list a into it.



              You can get a lot more sophisticated, like only capturing certain words, or counting the numbers, but this shows how flexible the :s command is.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 2 days ago









              Christian BrabandtChristian Brabandt

              16.2k2646




              16.2k2646












              • how wonderful ! thank you !!

                – user3203476
                2 days ago

















              • how wonderful ! thank you !!

                – user3203476
                2 days ago
















              how wonderful ! thank you !!

              – user3203476
              2 days ago





              how wonderful ! thank you !!

              – user3203476
              2 days ago











              2














              Maybe this:



              :%s/W/rr/g
              :sort u
              :g/^s*$/d


              The first puts a line break before and after each non-word character.



              The second command sorts the entire file with the option "unique", so all duplicate lines are removed.



              The third command deletes all lines that are empty or only contain whitespaces.






              share|improve this answer



























                2














                Maybe this:



                :%s/W/rr/g
                :sort u
                :g/^s*$/d


                The first puts a line break before and after each non-word character.



                The second command sorts the entire file with the option "unique", so all duplicate lines are removed.



                The third command deletes all lines that are empty or only contain whitespaces.






                share|improve this answer

























                  2












                  2








                  2







                  Maybe this:



                  :%s/W/rr/g
                  :sort u
                  :g/^s*$/d


                  The first puts a line break before and after each non-word character.



                  The second command sorts the entire file with the option "unique", so all duplicate lines are removed.



                  The third command deletes all lines that are empty or only contain whitespaces.






                  share|improve this answer













                  Maybe this:



                  :%s/W/rr/g
                  :sort u
                  :g/^s*$/d


                  The first puts a line break before and after each non-word character.



                  The second command sorts the entire file with the option "unique", so all duplicate lines are removed.



                  The third command deletes all lines that are empty or only contain whitespaces.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 2 days ago









                  RalfRalf

                  3,7201317




                  3,7201317





















                      1














                      You can use grep with the --only-matching/-o flag to accomplish this:



                      :%!grep -o 'w+|W' | sort -u





                      share|improve this answer



























                        1














                        You can use grep with the --only-matching/-o flag to accomplish this:



                        :%!grep -o 'w+|W' | sort -u





                        share|improve this answer

























                          1












                          1








                          1







                          You can use grep with the --only-matching/-o flag to accomplish this:



                          :%!grep -o 'w+|W' | sort -u





                          share|improve this answer













                          You can use grep with the --only-matching/-o flag to accomplish this:



                          :%!grep -o 'w+|W' | sort -u






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 2 days ago









                          Peter RinckerPeter Rincker

                          10.6k11828




                          10.6k11828




















                              user3203476 is a new contributor. Be nice, and check out our Code of Conduct.









                              draft saved

                              draft discarded


















                              user3203476 is a new contributor. Be nice, and check out our Code of Conduct.












                              user3203476 is a new contributor. Be nice, and check out our Code of Conduct.











                              user3203476 is a new contributor. Be nice, and check out our Code of Conduct.














                              Thanks for contributing an answer to Vi and Vim Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f19653%2fhow-to-get-all-distinct-words-within-a-set-of-lines%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                              Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                              Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form