SELE command with #2 && Name - visual-foxpro

Sele 2 && Conductor
I am asked to convert a Visual Fox Pro app to Asp.NET Core
I am having trouble finding out what this means.

In FoxPro, commands can optionally get four-letter abbreviated.
So that Sele is a lazy way to refer to the Select command and && Conductor is a code editor comment, similar to a hypothetical C# line like:
Select 2; // Conductor
Quoted from
Visual FoxPro 9.0 SP2 Help
SELECT Command
Activates the specified work area.
SELECT nWorkArea | cTableAlias
Parameters
nWorkArea
Specifies a work area to activate. If nWorkArea is 0, the lowest-numbered unused work area is activated.
cTableAlias
Specifies a work area containing an open table to activate. cTableAlias is the alias of the open table. You can also include a letter from A through J for cTableAlias to activate one of the first ten work areas.

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.

UFT - Select File from TreeView

I have recorded a script to Click on an XML file(highlight, right-click and open) from a popup treeview, the popup contains a number of files(varying amounts/types and they can appear in any order), the one I will always want to select always begins with 'AB', the numerics of the filename will change per test however:
SwfWindow("APPMAIN").SwfWindow("2000HOME").SwfTreeView("MainTreeList").SelectCell "AB99872","Object Name"
SwfWindow("APP-MAIN").SwfToolbar("SwfToolbar").Select "Open"
After Recording, I run the script, but I get the following error:
SelectCell :SelectCell :Cannot identify the specified item = AB99872 of the TreeView.
So my question is 2 part:
Why can it not select the file AB99872 after the initial record using SelectCell?
Considering that the filename will change per test(ie... AB*), what is the best way to automate this to be robust enough to select any Filename beginning with 'AB'. I did try UI Automation/Object Recognition and I used a regular expression like ^AB.* but UFT(v12.54) continually crashed with this approach.
You can use the tree's GetContent method and then use regular expressions to find the name of the node to select (then use that value in SelectCell.

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).

Invert assignment direction in Visual Studio [duplicate]

This question already has answers here:
How can I reverse code around an equal sign in Visual Studio?
(6 answers)
Closed 4 years ago.
I have a bunch of assignment operations in Visual Studio, and I want to reverse them:
i.e
i = j;
would become
j = i;
i.e. replacing everything before the equals with what's after the equals, and vice versa
Is there any easy way to do this, say something in the regular expression engine?
Select the lines you want to swap, Ctrl+H, then replace:
{:i}:b*=:b*{:i};
with:
\2 = \1;
with "Look in:" set to "Selection"
That only handles C/C++ style identifiers, though (via the ":i"). Replace that with:
{.*}:b*=:b*{.*};
to replace anything on either side of the "=".
Also, since you mentioned in a comment you use ReSharper, you can just highlight the "=", Alt+Enter, and "Reverse assignment".
Just a slight improvement on Chris's answer...
Ctrl+H, then replace:
{:b*}{[^:b]*}:b*=:b*{[^:b]*}:b*;
with:
\1\3 = \2;
(better handling of whitespace, esp. at beginning of line)
EDIT:
For Visual Studio 2012 and higher (I tried it on 2015):
Replace
(\s*)([^\s]+)\s*=\s*([^\s]+)\s*;
with:
$1$3 = $2;
In Visual Studio 2015+ after selecting code block press Ctrl + H (Find & Replace window) and check "Use Regular Expression" option, then:
Find: (\w+.\w+) = (\w+);
Replace: $2 = $1;
For example:
entity.CreateDate = CreateDate;
changes to:
CreateDate = entity.CreateDate;
Thank you #Nagesh and Revious, mentioned details added.
The robust way to do this is to use a refactoring tool. They know the syntax of the language, so they understand the concept of "assignment statement" and can correctly select the entire expression on either side of the assignment operator rather than be limited to a single identifier, which is what I think all the regular expressions so far have covered. Refactoring tools treat your code as structured code instead of just text. I found mention two Visual Studio add-ins that can do it:
ReSharper
MZ-Tools
(Inverting assignment isn't technically refactoring since it changes the behavior of the program, but most refactoring tools extend the meaning to include other generic code modifications like that.)
Please see this question: Is there a method to swap the left and right hand sides of a set of expressions in Visual Studio?
My answer to that question has a macro that you can use to swap the assignments for a block of code.
I've improved the expression a little.
Replace
(\t+)(\s*)(\S*) = (\S*);
with
$1$2$4 = $3;
The reason is, it will look for lines starting with tab (\t). It will skip the lines starting with definition. E.g.:
TestClass tc = new TestClass();
int a = 75;
int b = 76;
int c = 77;
a = tc.a;
b = tc.b;
a = tc.c;
Would ignore the int a, int b and int c and swap only the assignments.
what about replace all (CTRL-H)
you can replace for example "i = j;" by "j = i;"
you can use regular expressions in that dialog. I'm not so sure about how you should pop-up help about them however. In that dialog, press F1, then search that page for more information on regular expressions.
I like this dialog because it allows you to go through each replacement. Because the chance of breaking something is high, I think this is a more secure solution
You can do search and replace with regular expressions in Visual Studio, but it would be safer to just do a normal search and replace for each assignment you want to change rather than a bulk change.
Unfortunatly I don't have Visual Studio, so I can't try in the target environment, but if it uses standard regexps, you could probably do it like this:
Search for "(:Al) = (:Al);", and replace with "\2 = \1". (\1 and \2 are references to the first and second capture groups, in this case the parenthesises around the \w:s)
EDIT
Ok, not \w... But according to MSDN, we can instead use :Al. Edited above to use that instead.
Also, from the MSDN page I gather that it should work, as the references seem to work as usual.

I get this window while editing Ruby Files in Vim. What is it?

I usually get this new window open up suddenly while I am editing a Ruby file in VIM. This is getting irritating because, i cant type in anything while its processing. And it usually happens arbitarily. Does any one here know which plugin could be doing this? Or is this somekind of VIM's process?
This is happening when you hit K in normal mode.
K Run a program to lookup the keyword under the
cursor. The name of the program is given with the
'keywordprg' (kp) option (default is "man"). The
keyword is formed of letters, numbers and the
characters in 'iskeyword'. The keyword under or
right of the cursor is used. The same can be done
with the command >
:!{program} {keyword}
There is an example of a program to use in the tools
directory of Vim. It is called 'ref' and does a
simple spelling check.
Special cases:
- If 'keywordprg' is empty, the ":help" command is
used. It's a good idea to include more characters
in 'iskeyword' then, to be able to find more help.
- When 'keywordprg' is equal to "man", a count before
"K" is inserted after the "man" command and before
the keyword. For example, using "2K" while the
cursor is on "mkdir", results in: >
!man 2 mkdir
- When 'keywordprg' is equal to "man -s", a count
before "K" is inserted after the "-s". If there is
no count, the "-s" is removed.
{not in Vi}
If you notice, it's running ri in the open window, which is the ruby documentation app.
In Unixy environments, the help program normally runs inline, just displacing the vim output for a minute.
Is this using gvim, or command-line vim?
In either case, you can try monkeying with 'keywordprg' to fix the popup
Or, if you can't train yourself not to type it, you can just use :nnoremap K k to change what K does (in this case, just treat it as normal k command and go up one line).
I have this same issue on my work desktop, but not my home machine. The setups are near identical.
While stalking down a possible cause, I noticed that when I leave my cursor over a Ruby symbol such as File, Vim would popup a short description of the File class. After comparing all the various vim scripts and ri-related files that I could find, I finally settled on the only solution that worked...
Open $HOME/_vimrc and add the following line:
autocmd FileType ruby,eruby set noballooneval
Previously, I commented out a block in $VIMRUNTIME/ftplugin/ruby.vim, but Brian Carper suggested a better solution of :set noballooneval. I added the autocmd line so it is only executed with Ruby files.
If anyone figures out a true solution, please contact me. :(

Resources