vim advice on getting around - visual-studio

I have been using vim for a few days now and I really like the key bindings and the separate modes. I would really like to be able to be a little more efficient when using the various shortcuts etc.. that it has to offer.
For example I got a vim extension for visual studio and I had this line of code:
SqlCommand sqlcmd = new SqlCommand();
I wanted to get into the braces so I tried 5W, this took me to the first brace, then I pressed 'L' to go in and 'I' to go into insert mode.
I don't feel that I am using it to its potential, does anyone have any suggestions as to a quicker way they would have done that? or suggest things that I can look at to get even more efficient at editing using what vim has to offer, I would be really grateful.

Those two cheat-sheets will get you pretty far:

if your cursor is before the () on that line, you can try pressing:
%i
I think it would be the best way to go there. Of course you could do this as well:
f(a
to the question "how to get more productive"
think about those operations, you thought "complex/not productive" (like the one in your question)
try to find out a better solution by google/vim help/doc
use the new solution in your daily edit
if you cannot find better solution, ask here or other vim community, like vim-use mailing list.

Related

can I edit Xcode code completion suggestions?

I love the code completion in Xcode, it saves me a lot of typing work. Also, it confirms my code is probably error-free in real time. However, to me, some code suggestions are disturbing. For example, when I type else after an if-statement, Xcode suggests this:
else {
statement
}
I'd like to change this to just:
else
statement
Because, I quite often just want to use one line of code there, and adding curled brackets goes much faster than removing them. The other annoying thing is the fact that using such a suggestion takes the return key, while a new line does as well. So, if I would want to use my preferred way as shown above, I would first have to press the escape key in order to stop Xcode suggesting it, and then press the return key. Not a real pain, but I think it's unnecessary.
There are some other code suggestions which I would like to change, but I think I have made my point already. Is there a way to change these code suggestions? I know Apple doesn't provide an easy way within Xcode itself, but I'm willing to dive into the finder for the file with suggestions and change it manually. Thanks!
in your example, it would work to add a space after typing else. Doing that removes the brace suggestion and you can just hit enter.

Using wildcards in Selenium IDE

I'm somewhat new to automation, and am learning everything auto-didactically, so forgive me if my terminology is a bit off. I've searched hi and low for an answer to this question, and I can't seem to find anything. I presume it's my small vocabulary when it comes to this stuff... anyway...
I'm attempting to write a test that performs all the actions necessary to complete a tutorial by using the recorder. However, for one particular step, the element ID changes. For example, the ID I'm trying to click is this:
//li[#id='message_661119']/div[2]/div[2]/a/img
However, for each new user that is performing the tutorial "quest", the number of the id changes.
Is there anyway to get Selenium to recognize, or use, wildcards? Example:
//li[#id='message_******']/div[2]/div[2]/a/img
Of course, the example above does not work.
Any advice would be immensely helpful. Thank you!!
You can use starts-with() for this:
//li[starts-with(#id, 'message_')]/div[2]/div[2]/a/img
It's one of the examples mentioned in Locating Techniques in Selenium's docs for starts-with().
In Target field of the command in Selenium IDE where you can see message_123123 click on a dropdownlist and choose an option which is related to xpath:idRelative or if this one doesn't work then try another options which do not include that annoying message_123123 so this way you'll identify webpage element by it's location but not id. I solved my issue this way

What can I do in VIM that I can't already do in Visual Studio? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I heard it takes 30 days minimum to get comfortable with vi. I'm on day 2 hehe. Right now, I seem to be merely memorizing different shortcuts for things I already did in Visual Studio (incremental search, prev/next word, etc.).
So far the most powerful aspect seems to be the numeric keys combined with commands (5 * next line), and the idea of normal/insert modes.
There are a few things I miss from Visual Studio. Ctrl-Click'ing the mouse for quick copy and pasting is probably the biggest.
So that I don't get discouraged, can you guys walk me through some things in vi that you do regularly that can't be done in Visual Studio? It'll help me focus on what to learn and help me develop better habits.
I'll just leave a link to this SO answer here.
VI means never ever having to take you fingers off the keyboard.
Note that I don't use Visual Studio, and know little about the available features in it. The following are examples of what I find useful in Vim, not a list of missing features in Visual Studio.
Macros
It's easy to create macros for complex (but repetitive) operations. To illustrate with a simple example, let's say we start with:
Line1
Line2
Line3
Line4
Line5
Now we want to envelop each line in a print(""); statement.
Place the cursor on the first line, and enter:
qx to start recording a macro to the register x
Shift+I print(" Esc to insert text at the beginning of the line
Shift+A "); Esc to append text at the end of the line
j to go down one line
q to stop recording the macro
4#x to execute the macro in register x 4 times
See :help complex-repeat for more info on Vim macros.
Text objects
Note that this is one of the improvements Vim has over the traditional Vi. If it doesn't work, you're probably running in Vi compatibility mode; use :set nocompatible to enable the full functionality of Vim.
Text objects allow you to easily select regions of text. Let's say we start with the following text, and place the cursor on some text:
<b><i>some text</i></b>
Now we want to delete everything between <i> and </i>. This can be done by simply typing the command dit (d'elete i'nner t'ag)! Or if we want to include the tags themselves in our selection, use dat (d'elete a t'ag). To delete everything inside the <b> tags, use d2it (d'elete two i'nner t'ags).
You can similarly use daw (delete a word), dap (delete a paragraph), di" (delete inside double-quotes), etc; see :help text-objects for the complete list.
Another useful example of text objects:
v2ap"+y
v toggles visual mode. This makes it easier to see what you're selecting, and lets you adjust your selection with a series of multiple motions before you execute a command.
2ap selects this paragraph and the next one
"+ selects the system clipboard as register for the next operation
y yanks the selection to the given register
In other words, that command would copy two paragraphs from your text to the system clipboard (e.g. for pasting them here at StackOverflow).
Global editing
The global command is used to apply an Ex command to all lines matching a given regular expression. Examples:
:global/test/print or :g/test/p would print all lines containing the phrase test
:global/test/delete or :g/test/d would delete said lines
:global/test/substitute/^/#/ or :g/test/s/^/#/ would search for lines containing the phrase test, and comment them out by substituting the regexp anchor ^ (beginning-of-line) with the symbol #.
You can also do some cool stuff by passing the search motions /pattern or ?pattern as ranges:
:?test?move . searches backwards for a line containing test, and moves it to your current position in the file
:/test/copy . searches forwards for a line containing test, and copies it to the current position in the file
Good luck and have fun learning Vim!
Edit a file on a Solaris machine that only allows SSH access.
This article is what got me started on Vim, and I never looked back:
http://www.viemu.com/a-why-vi-vim.html
It has some great examples on Vim's power.
Use screen to keep a session running on a remote machine accessed over ssh
Visual Studio's regular expressions are a little bit Mickey Mouse. Vim has the full POSIX regular expression language at your fingertips.
As far as I can tell (in Visual C# express 2010) ctrl-click just selects whatever word you click on. To do the same in VIM, you can combine the yank command with a movement command.
So you press "y" for yank (copy) then "e" or "w" to copy to the end of the word.
There is many differences.
Block (and column) wise copy, paste, edit
the dot command! (after duck tape the second most powerful tool on the planet, seriously)
I suggest you watch some screencasts at http://vimcasts.org/ to get a feeling of the power of vim.
e.g.:
http://vimcasts.org/episodes/creating-the-vimcasts-logo-as-ascii-art/
http://vimcasts.org/episodes/selecting-columns-with-visual-block-mode/
You could always use the Vim emulator/add-on for Visual Studio and get some of the power of vim mixed with the features of VS. If you're already using Visual Studio, I assume you're using a .NET language, which without VS, would be much more painful to use.
Vim Essentials is a nice set of slides.
Personally, I got used to vi a long time ago, when we didn't have the luxury of a mouse in student's Unix terminals. Since then, I used vi/vim for everything safe for writing emails.
To this day, I probably use only 1/20 of the commands, but never felt the need to write code with another text editor, and reaching for a mouse in an IDE feels very clumsy to me.
Using high level and expressive languages, that do not require an IDE (mainly python, sql, javascript) really helps. I suppose it wouldn't be as easy with Java or C++.
Not having to move and point with the mouse when coding (safe for using the browser) also helps preventing Carpal tunnel syndrome.
BTW, I suppose Vim integrates better with Unix than with Windows... and who said 30 minutes was a little optimistic :)
Edit documents over SSH. Vim's really nice for that.
Edit: looks like a lot of people have already said that :)
teco is your answer. You only need a PDP-10 and an ASR-33 and you're on your way!

How can I undo more than a single character in TextMate?

TextMate may be the best editor out there, but is has a big disadvantage: it undoes each character typed instead of grouping characters. This makes a large undo tedious!
Do you now any hacks, plugins or workarounds to fix this issue?
I know the developer's been promising a fix for years now, and it's something the user community complains about a lot. But I don't think I've seen anything more useful than "hold down Cmd-Z to repeat".
This is not exactly what you're asking for but more a work around because as dnord said, this is a fundamental issue with TextMate and won't be fixed until Allen Odegard decides to fix it.
Have you considered trying one of the clipboard managers out there? At least that way you can clip chunks of text and 'undo' them at will.
I use Jumpcut because it's free and does the job.
Just in case anyone doesn't already know this: Shift-Option-Arrow lets you select things word by word.
If you make a habit of selecting whole words before deleting text, you'll save time when you do and when you undo.

Is it possible to add multiple commands to the readline .inputrc file?

I'm trying to configure my Terminal and I would like to insert #{} at one key-stroke. This works with the following code
# .inputrc
"\e\"": "#{}"
But I also want the cursor to end up inside the braces. How can I do this? The following doesn't work.
# .inputrc
"\e\"": "#{}": backward-char
Try:
"\e\"": "#{}\e[D"
My immediate way to fix your overall goal (not really answering your question, but hopefully helping you anyway): write a bash alias or function for it. grev() perhaps, or something similar - at least, this is what I would do were I in your situation.
I am interested to see if what you originally asked is possible, however, so voting up your question in hopes that you can get a 'real answer'!

Resources