In netbeans how can one format it so that after if-blocks there is a blank line? I have been searching through the formatting options and trying different things to no avail.
e.g.
if ($lifegivesyoulemons) {
echo "say f' it and bail";
}
if ($if_they_take_my_stapler) {
echo "i will set the building on fire";
}
Not specifically for if-else loop this should work for all methods also.
In your Netbeans IDE goto Tools - then select Editor tab.
Under Editor tab select Formatting select language PHP (as per your if-else loop in question) and Category Blank Lines
And then scroll down in After Function field change value 0 to 1 like this
Click on Apply and Ok
Now select On Save tab. Select language PHP
Uncheck Use all language settings. After that from drop down select All Lines. Click on Ok
Now you type code hit Ctrl + S Netbeans automatically formats your code with one blank line after } brace (bracket). (As of I know this should work both methods and loops also).
I have some long C & C++ header files with a lot of nested #if statements in them.
#if FOO
...
#elif BLAR
#ifndef WIDGET
#endif
#else
...
#end
Is there a way to jump between matching statements in Eclipse? I have found a similar question that says it is possible in Visual Studio which suggests that the CTRL + ] key combination should do it, but that seems to only work for matching braces.
No, there is not a way. However, this bug report submitted in 2007 requests this feature: https://bugs.eclipse.org/bugs/show_bug.cgi?id=182579.
If you want this feature, go there and vote on it to raise this request's importance and give it more priority. You might also leave a comment.
Until this feature is added, a super lousy sort of work-around, as you suggested, is to use the "Find/Replace" dialog and "Find Next"/"Find Previous" shortcut keys, searching for the # character.
Steps:
Ctrl + F then enter # in the "Find" box. Press the "Find" button. This will jump to the next # character it finds. With the # character now cached in the Find/Replace dialog, you may close the "Find/Replace" dialog box and use the shortcut keys if you like:
Ctrl + K = "Find Next"
Ctrl + Shift + K = "Find Previous"
You may optionally change these keys via the settings under Window --> Preferences --> General --> Keys (source).
You may use CTRL+Shift+L to see the "Show Key Assist" List of shortcuts (depending on the context), as explained by this answer here. Continue pressing CTRL+Shift+L a couple more times to automatically open up the Window --> Preferences --> General --> Keys settings window.
Tested in Eclipse IDE for C/C++ Developers v4.7.3a in Ubuntu 14.04.
Please vote on the Eclipse feature request "bug" above to get the developers to add in a proper solution.
It seem that with the cursor on a #statment Ctrl+k will move down the file to a matching statement while Ctrl+K will move in reverse.
While writing this up I came across a Visual Studio 2010 question: How to jump to matching #if/#elif/#endif statements? This question states that Ctrl K / Ctrl J will do what I want in Visual C++ 6.0.
As shown above, the Eclipse specific key command also uses k.
I also found that Ctrl+L brings up a a list of keyboard shortcuts and lists the Ctrl+k as Find Next and the Ctrl+K as Find Previous. Pressing Ctrl+L a second time takes you to the Preferences > Keys menu where it is possible to add new combinations.
Is there a shortcut in Management Studio 2012 to delete the row where the cursor is.
Except Shift+Del, because this has the side effect on your text saved before with Ctrl+C is deleted after the shortcut.
Is should work like Ctrl+D in Eclipse.
Unfortunately, there is no shortcut in SQL Server Management Studio to delete a row.
Ctrl + x do the deleting job (by cutting and placing to buffer) entire line where the cursor are.
Which can be a useful alternative to setting "delete" shortcut manually.
In case anyone is looking for a way to do this WITHOUT cutting the line to the clipboard, the command you want is called Edit.LineDelete. You can get to it by going to Tools --> Options --> Environment --> Keyboard --> Keyboard and searching for the command in the text box.
You may also need to make sure that the key combination you're assigning it to isn't already being used by anything else.
I think you need to change short cut key from Tools - Options and then Keyboard.
See in below image.
Instead of, Shift + Del you can assign any, you want to set. (Except default keys)
I haven't been able to figure this out yet. Atom seems to use spaces as the default indentation mode. I prefer to have tabs instead though. Sublime Text has built in functionality for switching and converting indentation.
Anyone found out how to change the indentation mode of Atom?
Some screenshots from Sublime Text:
See Soft Tabs and Tab Length under Settings > Editor Settings.
To toggle indentation modes quickly you can use Ctrl-Shift-P and search for Editor: Toggle Soft Tabs.
Go to File -> Settings
There are 3 different options here.
Soft Tabs
Tab Length
Tab Type
I did some testing and have come to these conclusions about what each one does.
Soft Tabs - Enabling this means it will use spaces by default (i.e. for new files).
Tab Length - How wide the tab character displays, or how many spaces are inserted for a tab if soft tabs is enabled.
Tab Type - This determines the indentation mode to use for existing files. If you set it to auto it will use the existing indentation (tabs or spaces). If you set it to soft or hard, it will force spaces or tabs regardless of the existing indentation. Best to leave this on auto.
Note: Soft = spaces, hard = tab
Add this to your ~/.atom/config.cson
editor:
tabLength: 4
OS X:
Go to Atom -> prefrences or CMD + ,
Scroll down and select "Tab Length" that you prefer.
You could try going to "Atom > Preferences > Editor" and set Tab length to 4.
This is for mac. For windows you will have to find the appropriate menu.
Adding #Manbroski answer here that worked for me:
try Ctrl-Shift-P Editor: Toggle Soft Tabs
Late to the party, but a clean way to do this on a per-project basis, is to add a .editorconfig file to the root of the project. Saves you from having to change Atom's settings when you're working on several projects simultaneously.
This is a sample of a very basic setup I'm currently using. Works for Atom, ST, etc...
http://editorconfig.org/
# Automatically add new line to end of all files on save.
[*]
insert_final_newline = true
# 2 space indentation for SASS/CSS
[*.{scss,sass,css}]
indent_style = space
indent_size = 2
# Set all JS to tab => space*2
[js/**.js]
indent_style = space
indent_size = 2
This is built into core: See Settings ⇒ Tab Type and choose auto:
When set to "auto", the editor auto-detects the tab type based on the contents of the buffer (it uses the first leading whitespace on a non-comment line), or uses the value of the Soft Tabs config setting if auto-detection fails.
You may also want to take a look at the Auto Detect Indentation package. From the docs:
Automatically detect indentation of opened files. It looks at each opened file and sets file specific tab settings (hard/soft tabs, tab length) based on the content of the file instead of always using the editor defaults.
You might have atom configured to use 4 spaces for tabs but open a rails project which defaults to 2 spaces. Without this package, you would have to change your tabstop settings globally or risk having inconsistent lead spacing in your files.
I just had the same problem, and none of the suggestions above worked. Finally I tried unchecking "Atomic soft tabs" in the Editor Settings menu, which worked.
If you are using the version 1.21.1:
Click on Packages / Settings View / Open
Select "Editor" on the left side panel
Scrool down until you see "Tab Length"
Edit the value. I like to set it to 4.
Now, just close the active tab pane and you are done.
Tab Control gives nice control in a similar manner to that described in your question.
Also nice, for JavaScript developers, is ESLint Tab Length for using ESLint config.
Or if you're using an .editorconfig for defining project-specific indentation rules, there is EditorConfig
If you're using Babel you may also want to make sure to update your "Language Babel" package. For me, even though I had the Tab Length set to 2 in my core editor settings, the Same setting in the Language Babel config was overriding it with 4.
Atom -> Preferences -> Packages -> (Search for Babel) -> Grammar -> Tab Length
Make sure the appropriate Grammar, There's "Babel ES6 Javascript Grammar", "language-babel-extension Grammar" as well as "Regular Expression". You probably want to update all of them to be consistent.
If global tab/spaces indentation settings no longer fit your needs (I.E. you find yourself working with legacy codebases with varied indentation formats, and you need to quickly switch between them, and the auto-detect isn't working) you might try the tab-control plugin, which sort of duplicates the functionality of the menu in your screenshot.
When Atom auto-indent-detection got it hopelessly wrong and refused to let me type a literal Tab character, I eventually found the 'Force-Tab' extension - which gave me back control.
I wanted to keep shift-tab for outdenting, so set ctrl-tab to insert a hard tab. In my keymap I added:
'atom-text-editor':
'ctrl-tab': 'force-tab:insert-actual-tab'
Changing language-specific configuration
I changed the default tab settings, and it still did not impact when I was editing my files, which were Python files. It also did not change when I modified the "*" setting in ~/.atom/config.cson . I don't have a good explanation for either of those.
However, when I added the following to my config.cson, I was able to change the tab in my Python files to 2 spaces:
'.source.python':
editor:
tabLength: 2
Thanks to this resource for the solution: Tab key not respecting tab length
All of the most popular answers on here are all great answers and will turn on spaces for tabs, but they are all missing one thing. How to apply the spaces instead of tabs to existing code.
To do this simply select all the code you want to format, then go to Edit->Lines->Auto Indent and it will fix everything selected.
Alternatively, you can just select all the code you want to format, then use Ctrl Shift P and search for Auto Indent. Just click it in the search results and it will fix everything selected.
Yet another answer: If you are using Atom Beautify note that it has its own settings to determine the "Indent Char".
Is there a way to align the written C++ code in VS 2010? I want after selecting a block of code to apply a combination of button press and the code to be aligned as in Eclipse or Netbeans with Java.
Look at Edit -> Advanced -> Format Selection
The keyboard shortcut depends on your settings. It's Ctrl+K+F for me. (Under Options -> Environment -> Keyboard enter Edit.FormatSelection into the field labeled Show commands containing to add your own shortcut.)
for code block : ctrl +E,F (Edit -> Advanced -> Format Selections)
for document : ctrl +E,D (Edit -> Advanced -> Format Document)
Try using Ctrl+K+F on the selected text.
Is Ctrl + E, D what you're after?