VisualStudio 2012 keyboard shortcut (continue/for) - visual-studio-2012

When I want to see where my continue; jumps I have to delete ; and type it again (so something, let's call it Intellisense, will highlight continue and for or while line).
Same goes when I want to reformat something enclosed between { and } (in case formatting was not possible, because i wrote to example double a = inside and only after editing the rest could finish), I have to delete } (preferably the last one in the currently opened file) and type it again.
Question is:
are there keybindings to simplify this? Like pressing Ctrl+K and then something?
what are you guys doing, same as I deleting and retyping stuff to make things working?
P.S.: I know about Ctrl+Space (and one with the Shift) and I read this and also did some Googling, no luck.

Related

Why does various functions on sublime text 3 disappeared suddenly?

I was coding on sublime text 3 and I wanted to copy and paste a section of my code somewhere else.
So I did ctrl + arrow keys. But it didn't copy and paste like usual. It only moved the thing. So I tried again, but in vain. Also, I wanted to make a doc string. So I typed double quote two times and then moved the cursor in between the quotes to wright. But when I began to wright, it replaced the last double quote with my text. I tried again and it had the same result. I tried reinstalling it, but it didn't work. I searched on stack overflow and they didn't have my question. How can I fix it?
You accidentally pressed the Insert key or otherwise got your system into overwrite mode, instead of the standard insert mode. By pressing Insert again, this is reverted, and things will be back to working as normal.

Vim: Shortcut automatically inserted method, don't know how to replicate

I stumbled upon something in Vim that I'm not quite sure how I can replicate.
Basically I have this
var first_set = input[0].split(',');
var second_set = input[1];
I had my cursor somewhere between the ] and ; on the second line, accidentally fat-fingered a key near i on my keyboard, and it instantly popped out what I was going to type.
var second_set = input[1].split(',');
I had previously inserted .split(',') to the first line.
Is there a Vim shortcut that automatically takes your last edit and spits it back out? I really can't figure out what Vim did that would know I wanted the exact same method. Even my autocomplete <C-n> doesn't go that far to even put in the same arguments.
Hopefully this isn't too obvious but you can use the . command to repeat the last command you did, also if you had deleted some piece of text then p would paste it. If this is an action that you do often you can create a macro that would automaticly transform something like input[1] into iniput[1].split(','). Also you can use a snippets plugin to expand things like spl into what you want.
There's many options :).

VIm change bracket types (without using search and replace) [duplicate]

This question already has answers here:
Quickest way to change a pair of parenthesis to brackets in vim
(6 answers)
Closed 8 years ago.
I am looking for a VIM key combo for changing something like
blahblah["hello"]
to
blahblah("hello")
My best effort so far is
0f[yi[%c%()^["0P^[
but anything better would be much appreciated.
BTW, my combo works by doing:
find the first instance of [ (you get my point),
yank the insides (which of course means to register 0 by default, and it leaves the cursor on the first "),
move the cursor back onto the first instance of [ with %,
delete the whole [...] bit and go into insert mode,
write () and <Esc> out of insert mode,
paste the contents of register 0 in between the ().
I was hoping to have a muscle-memorable key combination that I could use for things like this where you want to 'keep the contents but change the surroundings'.
My proposal, if you reduce it to the minimum (and use ca[ rather than %c% -- credit to this SO for the a motion that I had not really known about) is not too bad because it is the sort of thing you can invent again once you know it is possible:
yi[ca[()<Esc>"0P
However, it occurred to me that a search-and-replace is going to be just the right kind of solution when you need to do a few of these in a file. Here is my best effort:
select the area in visual mode (I tend to use VISUAL LINE mode as a default),
then :s/\[\(.\{-}\)\]/(\1)/g<Enter> and you're done.
That itself looks a bit mad, but it is just a simple example of so-called backreferencing so I was quite happy to have had to get that clear in my mind too.

Keyboard shortcut to "Comment" a line in NANO?

I love NANO. It's always there, it can slice and dice, and its NOT VIM!
But I am constantly hitting Command / - inadvertently - as I go along, out of habit.. Most IDE's use this convention to "comment out" a line.
NANO has great syntax highlighting.. so it knows the context of my documents.. but I haven't been able to figure out a way to get it to perform this basic, yet relatively important function.. Hand-commenting is for the birds.
I suppose this is sorta a super-user question, but in my experience, this would get a bunch of blank stares and then a few people asking who Nano was, so... here it is...
Oh and PS, brownie points for anyone that knows how to get DashCode to be able to do this as well... It would be the finest Javascript IDE EVER if it could perform this trick... and I'm convinced Apple omitted the feature for just that reason, lol.
The simplest workaround I've found:
Comment-out:
set the cursor at the first row that should be commented-out
hit twice 'M-R' (or 'Alt-r'; in order to Replace a RegExp)
Search for: '^'
Replace with: '# '
Replace this instance?: 'y'
press 'y' for each row to be commented-out
Comment-in:
The same procedure, replacing '# ' by ''
New in nano 2.6
(2016 June 17)
comment/uncomment lines with default binding M-3 (Meta-3)
(http://git.savannah.gnu.org/cgit/nano.git/tree/NEWS)
Customization
If you do not like the default mapping, note following:
Using Ctrl-/ by rebinding it in ~.nanorc with bind ^/ comment main is not possible. On a linux console this is equivalent to a backspace (https://savannah.gnu.org/bugs/?53248).
Some possible alternatives could be:
Meta-; (emacs)
Alt-/ (micro)
While accepted answer is de jure correct, it doesn't really help if you're not proficient in Nano already.
Indeed since Nano 2.6 this functionality is available as M-3 (Meta-3). But what it actually means (see doc) is that comment\uncomment can be done via these hotkeys:
<Alt> + 3 // <Alt> is default <Meta> command
<Esc> + 3 // Single <Esc> should also work
And since usually you need to comment out several lines, you can use Alt + a (or Meta + a / Esc + a) to switch to selection mode which will allow to select several lines. Then comment command will be applied on all selected lines at once.
Related question: How to comment multiple lines in nano at once?

What should I use vim Visual mode for?

I have been using vim for a couple of years now, and though I have learnt a lot of time saving shortcuts, but I have never used the Visual mode, which is supposed to be all powerful :
... Visual block mode (to edit columns) is something many editors lack, but that I can't live without. I have shocked and awed people at work using just this, making some edit in a few keypresses that someone would've otherwise spent ten minutes doing manually.
I want to understand why and when should I be using Visual mode.
Can someone give me an example of "making some edit in a few keypresses that someone would've otherwise spent ten minutes doing manually"?
If you see CTRL-CCTRL-V and recognise what it does, you should use visual mode.
If, like me, you see A:esc0df:$p$x as an edit command, don't bother :-)
When I use visual mode, it's to select whole lines or blocks. For example you can do [esc][shift+v][y] to copy the currently line I'm on. Here's more information.
Visual mode allows you to perform an operation on a block of text. It is the only way to perform an operation on a block in Vim.
A simple example of this would be copying or moving text.
A more advanced example would be sorting the lines in a certain part of a file. You can do this by entering visual mode, selecting a block of text, pressing Esc to enter command mode, and typing !sort. You can see more details about his example and how it works here: http://www.oualline.com/vim-cook.html#sorting_visual
I actually just did a screencast showing off great uses for visual mode. You can check it out at http://lococast.net/archives/241
As other's have said, it's great for doing any sorts of editing (edit, remove, search/replace) withing a specific range of code.
Insert a column of commas.
Delete a column of commas.
Act on rectangular selections.
Act on a section of text that is not a line or word.
Several good examples have already been given. Here are some others.
I also use visual mode:
To swap two regions of text.
To refactor out variables, types, and functions.
To surround the selection with pair of things (usually brackets)(NB: surround.vim also does this I guess), but also with control statements.
But simply most of the time to have a more interactive way to yank or change text.
To paste over without overwriting the current unnamed register.
To highlight the current selection (with Mark.vim)
And to do many other things I don't remember right know.

Resources