What is the most common word in EmEditor - emeditor

I got like 30mlion words in Emeditor format looks like:
Money
Love
Money
France
Telephone
Fork
.
.
.
I would like to know which word has the most repetitions. its possible to check it?
I dont want do it manualy like bookmarking or find next.
I would like it in this form or in any other:
3200 Money
3190 Love
etc.

In EmEditor, select Extract Frequent Strings on the Search menu, accept the default options, and click OK.
The result output of your sample will be like this:
If you prefer a macro, use this line:
document.selection.ExtractFrequent(eeFreqTypeLines, eeFindReplaceCase, 1, 100, "");
To run this, save this code as, for instance, Macro.jsee, and then select this file from Select... in the Macros menu. Finally, select Run Macro.jsee in the Macros menu while a document with a list of words is active.

Related

How to remove word in a visual selection in Vim

Suppose I have the following input as shown below. What I would like to do is to visually select lines 2 through 4 (shift + v) and then delete the word dog.
How can I do that? I know I can use something like :s/dog// on my selection, but I was wondering if there's a more straightforward way.
1 The quick brown dog
2 dog jumps
3 over the
4 lazy dog,
5 but it should be just a fox.
The final output should be (affected only by the visual selection on lines 2 through 4):
1 The quick brown dog
2 jumps
3 over the
4 lazy ,
5 but it should be just a fox.
That's impossible.
Why?
tl;dr
I think, you are envisioning something like a normal mode within visual mode (so that you can "move and delete like in Vim" while you are in visual mode). Such a thing doesn't exist.
Think about it: if you visual select some lines, then those lines, and nothing else, are the object of whatever action you do next (d, s, c, or whatever).
But you want to take an action not on those visually selected lines, but on words within them. But how can you tell Vim to take action on the words dog and not on other words? You can do that with movements, but as long as you are in visual mode, that's not possible, because any movement will just change the visual selection, and not allow you to somehow move within it.
This means that you need to abandon the visual selection so that you can move to those words and use them as the textual object for the action.
If you really want to start from the visual selection, then the only way to give the info that you want to take action on the words dog, is to type them out while you are in visual mode. And that's precisely what the :s approach does.
You can take advantage of the marks '< and '>: they store the start/end position of the visual selection and they keep their value after you exit the visual mode.
In command line mode, Ctrl-RCtrl-W inserts the word under the cursor.
By combining this, you can create a mapping like that:
noremap <c-d> :'<,'>s/<c-r><c-w>//<cr>
Then to use it:
first select the wanted zone with V;
hit Esc to exit visual mode;
move your cursor under the word you want to delete;
then trigger the mapping, in this example Ctrl-D.
I think there is no way in way to just replace a specific word in specific lines with visual selection. You can also use sed for that (look at #5).
Anyways:
Here are 4 way to delete the word dog in a file and one way to do it with sed:
1 (with visual mode):
Type v to enter visual character mode
Highlight dog
Press d for deleting
2 (with substitute and confirmation):
:%s/dog//gc
g stands for global
c stand for confirmation
You will be ask for every entry, what to do with.
3 (with substitute):
:2,4s/dog//
4 (with search mode):
/dog
Type: n for next match
Type: d for deleting the match
For further information: Search and Replace
5 (with sed):
sed 2,4\s/dog// filename
When you are in visual mode, pressing : automatically inserts the visual range in the command-line so whatever Ex command you use after that is going to work on the visually selected lines:
: becomes :'<,'>, in which '<,'> is a range beginning on the first line of the visual selection and ending on the last line of the visual selection.
After that, you can do s/dog<CR> (no need for the //) to substitute the first dog with nothing on every selected line. This is effectively equivalent to doing :2,4s/dog<CR>.
From a semantic point of view, :s/dog<CR> is as close as you can get with the built-in features to "remove dog in the current visual selection" so, barring making an hypothetical custom mapping that would only save a couple of keystrokes, you are unlikely to find a more "straightforward" way.

Click Element Robot Framework case sensitive

I have the same button in two different application , so i want to write the same code for them , but the pb is that there's a difference between the xpaths in the text , one starts with an uppercase letter and the second all in lower case :
xpath1: //span[contains(#class,'text')][contains(text(),'Test')]
xpath2: //span[contains(#class,'text')][contains(text(),'test')]
so i want to use the same function: Click Element ${element}
for both apps , how to do that ?
THANKS
I'm using below format, it works perfect. So you can have multiple xpath using this union operator "|". There are also multiple options, but this works and easy to use.
//span[contains(#class,'text')][contains(text(),'Test')] | //span[contains(#class,'text')][contains(text(),'test')]
or
you can also use below format, but this looks little dirty.
//span[contains(#class,'text')][contains(text(),'Test') or contains(text(),"test")]

Display number of filitering results sets

According to my question
Begin-/Endfilter
Is it possible in EmEditor to display the number of filtered results sets (could be equal to number of lines, if not using the Begin-/Endfilter) in the status bar of EmEditor; i found no options in the settings?
After you filter, how about searching for the end filter with the Count Matches option?
If you use a macro, I added the Find line to the last of the previous macro. You can use this macro instead:
filters = document.filters;
filters.Clear();
filters.AddFind( "|Column1", eeFindReplaceCase, eeExFilterBegin );
filters.AddFind( "| Number of Records:", eeFindReplaceCase, eeExFilterEnd );
document.filters = filters;
document.selection.Find( "| Number of Records: ", eeFindCount | eeFindReplaceCase );
You can run this macro after you open your data file. To do this, save this code as, for instance, Filter.jsee, and then select this file from Select... in the Macros menu. Finally, open your data file, and select Run in the Macros menu while your data file is active.
Before you run this macro, please deselect the Show Execution Time option in the Status page of the Customize dialog box.

automate creating sql statements using scripting tool

I often have a task a bit like this: insert a large number of users onto to the users table with similar properties. Not always that simple, but in general, list of strings -> list of corresponding sql statements.
my usual solution is this with the list of usernames in excel use a formula to generate a load of insert statements
=concatenate("insert into users values(username .......'",A1,"'.....
and then I fill down the formula to get all the insert rows.
This works but sometimes the statement is long, sometimes including a few different steps for each, and cramming it all into an excel formula and getting all the wrapping quotes right is a pain.
I'm wondering if there is a better way. What I really want is to be able to have a template file template txt:
insert into users
([username],
[company] ...
)
values('<template tag1>...
and then using some magic command line tool, to simply be able to type something like
command_line> make_big_file_using_template template.txt /values [username1 username2]
/output: bigfile.txt
and this gives me a big file with the template repeated for each username value with the tag replaced with the username.
So does such a command exist, or are my expectations of command line tools too high? Any freely available windows tool will do. I could whip up a c# program to do this in not too much time but I feel like there must be an easy to use tool out there already.
This is trivial using a Powershell script. PS allows inline variables in strings, so you could do something like:
$Tag1 = 'blah'
$Tag2 = 'foo'
$SQLHS = #"
INSERT INTO users
([username],
[company],...)
VALUES
('$tag1', '$tag2'...)
"#
set-content 'C:\Mynewfile.txt' -value $SQLHS
The #"...."# is a here-string, which makes it very easy to write readable code without escaping quotes and such.
The above could be very easily modified to accept parameters for the various tags and another for the output file, or to run for a set of values located in another .txt or .csv file as inputs.
EDIT:
To modify it to accept parameters, you can just add a param() block at top:
param($outfile, $tab1, $tab2, $tab3)
Then use those $variables in your script:
set-content "$outfile" -value $SQLHS

VIM Blockwise Insert

I would like to insert a hash at the beginning of a selected block of text in VIM (ruby comment). I selected the lines in Visual Mode, but how do I perform the same operation to all lines?
You have two primary options:
Select in block visual mode (ctrl-v), then use I to insert the same thing along the left side of the entire block. Similarly A appends; see blockwise operators.
Select the lines in normal visual (v) or visual line (V) mode, then run the same command on all of them, for example s/^/# / or normal I#. Typing : while you have a visual selection automatically uses the visual selection as the line range (denoted by '<,'>).
While in visual mode do the
:'<,'>s/^/#
actually, '<,'> will be inserted automatically when you hit :.
You better use this.
COMMAND MODE with set number to see lines
:10,50s/^/#/g
First number before comma is the start line and second number after comma is the end line. Both are included.
Another question might have copied this question, so came here from How to Insert in Visual Block Mode.
Highly recommend that people take a look at this cheat sheet: http://www.rayninfo.co.uk/vimtips.html
As people do more research into VIM people will see a lot of %s/^/# with the % sign in front and by replacing the % sign with what pops up in Visual Block Mode with :'<,'> the symbols that pop up you are able to do insert, etc.
:'<,'>s/^/# (applied on selected lines only)
:%s/^/# (applied globally)
(sharing my two cents after researching how to add a hrefs' to different lines).

Resources