I'm using Notepad++ as an editor to write programs in Python. It might sound daft but I looked around in the editor and could not find any means (not the manual way but something like in Emacs) to do a block comment in my code.
Since so many language settings are supported in Notepad++, I'm curious to find a way to block comment code.
CTRL+Q Block comment/uncomment.
See Keyboard And Mouse Shortcuts - Notepad++ Wiki.
Try the following shortcut:
Ctrl+K.
This link was exactly what I was searching for .
Let me summarize the answers for others' benefit (for python and notepad++)
1) Ctrl+K on multiple lines (i.e. selected region) allows you to block comment.
Also note that pressing the combination multiple times allows you to add multiple "#"s (sometimes I use that while testing to differentiate from other comments)
2) Ctrl+Shift+K (on the commented region) allows you to perform block uncomment
3) Ctrl+Shift+K on an uncommented selected region does not comment it
4) Ctrl+Q allows you to block comment/uncomment in a toggled mode (meaning, you cannot add multiple '#'s like in 1) )
Hope this helps another wandering soul.
Question - how would you develop a hack of keyboard combinations to comment/uncomment if there were no shortcuts? Just curious. I've no clue hence asking.
Yes in Notepad++ you can do that!
Some hotkeys regarding comments:
Ctrl+Q Toggle block comment
Ctrl+K Block comment
Ctrl+Shift+K Block uncomment
Ctrl+Shift+Q Stream comment
Source: shortcutworld.com from the Comment / uncomment section.
On the link you will find many other useful shortcuts too.
for .sql files Ctrl+K or Ctrl+Q does not work.
to insert comments in .sql files in Notepad++ try Ctrl+Shift+Q
(there is no shortcut to uncomment the code block though. I have tried that on v5.8.2 )
Use shortcut: Ctrl+Q.
You can customize in Settings
In your n++ editor, you can go to
Setting > Shortcut mapper
and find all shortcut information as well as you can edit them :)
Two ways for block commenting:
Ctrl+Shift+Q
or
Select the block
Alt + Right click
Choose block comment.
Without having selected a language type for your file there are no styles defined. Comment and block comment are language specific style preferences. If that's a PITA...
To select for multi-line editing you can use
shift + alt + down arrow
To add a comment under any code on NOTEPAD++ first we have to save and define the programming or scripting file type. Like, save the file as xml, html etc. Once the file is saved in proper format you will be able to add a comment directly using the shortcut ctrl+Q
Just select the desired line and click on Ctrl + Q
Ps: I am using Notepad++
Related
I'm editing a hugh Javascript file. For better orientation, it would be cool if I could change the style of all function keywords (not changing the style of all other keywords).
Can this be done in VS 2012 with Resharper?
Actually you can do this without ReSharper. Press ctrl+f, type "function", press enter and don't close find window. All occurences of word
"function" will be highlighted and you can continue your editing. When you close find windows, highlighting will be gone.
It's acutally not so hard to write a VS extension that does that or similar things. See templates etc. here: http://msdn.microsoft.com/en-us/library/dd885242.aspx
I'll mark this as the accepted answer as soon as I can.
What are the best code blocks short cuts ? Also is there some way we can directly indent all our code ? In addition how can we move through the active tabs in codeblocks ?
Tips about tab identation are helpful when you write your code from begining. But if you paste code in CodeBlocks from some external source, like PDF document, that code often will not have good identation.
In this case, you need to select code, right click on it, and choose Format use AStyle option.
This is a plugin for CodeBlocks for right text formatting.
I hope this will help someone!
You (these are the default settings I believe) can select a block of code and press the Tab key. This will indent the entire block.
So for indenting a whole file: Ctrl + A, then Tab.
In addition, you can use Shift + Tab on a selected block to "unindent"
You can move through the open tabs with Ctrl + Shift + Tab.
As for the best shortcuts:
I like Ctrl + D to duplicate a line and
Ctrl + L to copy it.
Anyway, you can set whatever shortkeys you like in the Editor menu (there you will also be able to find all shortkey currently set).
]2
Add shortcut as you wish from Settings->Editor->Keyboard shortcuts->plugins->Source code formatters(Astyle) or use Plugins->Source code formatters(Astyle)
CTRL+A to select the code and TAB for alignment.
I have not had much luck with the code formatter in C::B. I like my code to look like this...
if (blah..) {
SomeCode();
} else {
DifferentCode();
}
it allows more code to fit on a screen, and is still reasonably readable.
After trying to tweak the settings in Settings->Editor, then Source Formatter tab, when I went to format my code, it removed the if line entirely, and I have not been able to unset my tweaks to make it work.
Fornatually, ctrl-z still works.
The code formatter should never remove code, only play with white space.
Maybe there is a better plugin.
Mark.
In addition in How to switch between tabs in codeblocks.
codebocks 20.03
Linux (KDE Neon)
To switch between tabs.
Activate this with CTRL+SHIFT+TAB, then you can use the know options:
CTRL+TAB , to switch to the right tab.
CTRL+SHIFT+TAB , to switch to the left tab.
Or this other option, but this is not in the keyboard shortcuts, this option doesn't work in a cycle mode, when your get the last right tab, it jump to the bottom tabs:
CTRL+ right-arrow-key , to switch to the right tab.
CTRL+ left-arrow-key , to switch to the left tab.
Remember to activate with CTRL+SHIFT+TAB.
After you land in the desire tab you can type TAB to begin to start writing code.
I'm refactoring some code and there are tons of functions with no try catch statements that are causing problems.
Is there a keyboard shortcut in VS 2010 to allow me to select an entire function or highlighted code and add a try catch end try statement around it...with the highlighted code automatically ending up under try ?
Just looking for a shortcut
I'm not aware of a keyboard short-cut, but there's a right-click available.
Highlight the code for your try block.
Right click and select
"Surround with..." Scroll down the selection until you see the "try"
snippet label.
There you go!
Hope this helps!
I'll dig around to see if there's a keyboard short cut for this. There probably is -- there's hundreds of them.
UPDATE: Looks like the keyboard shortcut is Ctrl + K, Ctrl + S.
Download this free addon and then right click and surround with !
(Don't forget to give it 1+ )
https://marketplace.visualstudio.com/items?itemName=yatki.vscode-surround
It's not built in, but it is easy enough to roll your own.
Look into using the built in macro facility.
2023 Update
they added this functionality, but only for JS/TS... Let's hope they add this also for other languages like python soon!
Does anybody know a light plug-in that do (same as Resharper) go to implementation and the quick search for a file where you just insert few characters and it shows the matches? I just want to get rid of Resharper cause it slows me down a lot!!
To answer the original question, as per this post by Andrew Arnott, you can use Ctrl+/ to move the cursor to the Find text box in the toolbar, then type ">of" and start typing file names. The matching files will appear as you type.
Using the ">" prefix causes the find text box to act as the command window would.
(Note that the Ctrl+/ short-cut may be overridden by ReSharper to comment a line of code, so this short-cut only works with ReSharper uninstalled.)
That's interesting. I use ReSharper and it uses about 400mb of RAM. I would consider that pretty low usage.
Maybe you can look into Productivity Power Tools (I don't use it).
http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/
i have managed to make a code snippet and its all good, the question is i dont want to use ctrl+k ctrl +S then click on the snippet , instead i want to use a combination of keys to just use the snippet right away , or at least pressing ctrl+k ctrl + S then another combination ?
is that possible ?
thanks in advance...
If you say you're pressing Ctrl+K, Ctrl+S is because the snippet you added was a Surround With snippet, isn't it?
I suggest you installing ReSharper for this purpose. You can easily add all kind of snippets (called templates in ReSharper), and of course, Surround-With snippets.
After adding a template, you can give it the number you want.
Then all you have to do is press: Ctrl+Alt+J and you will see the following:
And all you have to do is press the number of the snippet you want.
For example, if you want to surround some code with an if, you press: Ctrl+Alt+J, 1.
Note:
In this moment, I don't really remember if Ctrl+Alt+J is the keyboard shortcut by default, because I have changed many of them, but you can check it in ReSharper > Edit > Surround With Template...
Easier than typing a key-combination is just typing the name+[Tab]+[Tab]. Visual Studio is pretty good at remembering the last ones used to make it even easier.
"f+[tab]+[tab]" creates a for loop snippet.
In your code snippet file, you can set up a shortcut element. Your code snippets are located under(depending on language):
"\Documents\Visual Studio 2010\Code
Snippets\Visual C#\My Code Snippets"
Under the CodeSnippet\Header\Shortcut section in the code snippet file, type a unique short relevant series of characters.
<CodeSnippet>
<Header>
<Shortcut>spi</Shortcut>
</Header>
Typing these characters followed by tab in the code window will insert your code snippet.