Is there a keyboard shortcut to toggle between single quotes and double quotes in a Ruby code? Or a key I can set up to accept the Inspection Hint?
Thanks, M.
To accept any inspection hint in RubyMine, press Alt+Enter and then use the arrow keys and Enter to select the quickfix to apply.
Current as of RubyMine 2016.2, there is an easier way to convert all quotes via the keyboard:
select part of string whose quotation type you want to change
Alt + Enter to accept inspection hint
Arrow right
"Fix all 'Double quoted string' problems in file"
Suppose you have a double quoted string as "some_string" then you need to select all "some_string" including both the quotes and press quote key to get 'some_string' i.e single quoted string. To get the double quotes 'some_string' => "some_string" follow the same process and press shift+quote key. Hope your problem is solved #Martin.
Related
I am processing some CSV data from a client and one of the headers is 'booktitle'. The values of 'booktitle' are text qualifed with double quote and there are quotes in some of the titles, such as;
"How to draw the "Marvel" way"
I asked the client to escape the quotes in quotes with double quotes, and they sent me back this
'"How to draw the """Marvel""" way "'
So single, double, then triple quote. My question is will this work? I have not seen it done this way before for escaping text qualifiers.
Which way are you using to save the info?
If you are saving it directly from SQL, double quotes are not a problem as SQL use single quotes.
If you are using a program, use SqlParameters. It will wrap you everything
Oracle Setup:
CREATE TABLE BOOKS(
ID INT,
TITLE VARCHAR2(4000)
);
CSV:
ID,TITLE
1,"How to draw the ""Marvel"" Way"
2,"Test ""Someone's Data"""
(One double quote at start and end, two double quotes to escape a double quote in the middle of the string and single quotes don't need to be escaped.)
Import via Oracle SQL Developer
In the connections pane, right click the table name and select "Import Data..."
Browse and select the CSV file then the default values will be sufficient so click "Next >".
Set the Import Method to "Insert" and deselect "Send Create Script to SQL Worksheet" then click "Next >" three times.
Click "Finish" and the data will be imported.
Is there a way on IntelliJ to remove surrounding parenthesis, brackets, quotes, etc? For example, if I have:
"string"
Is there any way to remove the matching quotes and get this?
string
Not directly, but the following replace expression (ctrl+R, tick Regex) might help:
Search for: "(.*)"
replace with: $1
Edit: I found an easier way (plugin code with regex left below for nostalgia)
Webstorm has extend selection and shrink selection
on mac they are bound to alt-upArrow and alt-downArrow
You can use extend selection to select the content and the quotes/braces/parens, then record a macro (i called mine unwrap) and perform the following actions:
shrink selection once
copy
extend selection once
paste
then you can save the macro and add a key binding.
Any time you want to unwrap something, you can just extend the selection until it includes the outer braces, then hit your hotkey and it will replace the selection including the braces with their inner contents.
I made a mini-plugin,
which i install/code using live-plugin.
It relies on this Regex:
[\["'({](.+)['"})\]]
The Regex will also often work in the Search/Replace function in webstorm
(with Regex and In Selection checked), but it fails in mysterious cases:
eg. single quotes that are inside parens - even if the outer parens are not in the selection to be considered
IDEA have an action to go to matching brace.
You can create macro with something like: goto next brace - delete one char - goto prev brace - delete one more char.
And then set kb shortcut to this macro.
Splice Sexp, which is Alt+S on Mac.
I occasionally need to go line-by line and change the indentation of the code.
Is there a shortcut in Pycharm where I can add spaces (format the indent) in the begining of multiple lines simultaneously without processing each line individually?
Highlight/ select the lines you want indented, then press TAB as often as needed until they reach the proper indent level.
You can remove spaces with SHIFT TAB.
You can also use CTRL+ALT+I to auto-indent the selection.
Select the block that you want to indent then press TAB. It will work.
To auto indent all the codes in Pycharm just press these sequencies:
CTR + A to select all the text files and then press
CTRL+ALT+I
Select all that you want to indent, then do CTRL+ALT+I to indent all of it. This should work in Pycharm
Use shift +alt on windows machine
Continuation indent for Mac pro: Preferences -> Editor -> Code Style -> the language -> Tabs and Indents
If Ctrl + ALT + I is not working and every time needs to press the Insert button to get the pointer.
So go to Tools -> Select Vim if it is checked then it will be disabled.
Now you can intend code directly selecting multiple lines.
Is there any way (Plugin, Script) to add quotation marks (or square brackets or parentheses) at the beginning and the end of selected text via a keyboard shortcut in the Kate editor?
I think of something like selecting a word and then pressing Ctrl-U (this would upcase the selected word). Is there something similar for quotation marks?
The "Configure Shortcuts" menu does not provide this option.
This should be possible to do by using Kate's Javascript plugin system: http://docs.kde.org/stable/en/kde-baseapps/kate/advanced-editing-tools-scripting.html.
By finding the word at the current cursor position and inserting text before and after, you could create a “surround with quotation marks” function.
For an example of a Kate script, see here: http://kucrut.org/move-cursor-to-next-prev-paragraph-in-kate/.
One solution would be the following:
Go to Settings > Configure Kate > Editing
Activate the Auto brackets option
Now you are able to wrap the selected text with brackets.
Though there is one drawback. The Auto brackets option is "always on", meaning that once you type "(" the corresponding ")" also comes up.
I was programming in PHP and typing mysql_connect, and by default the single-quotation is automatically closed, so I would have something like this mysql_connect('localhost[cursor is here]'). I still need to type my username and password, it just seems really out of the way to press the right arrow key to escape the single-quotations for writing the other arguments (username/password). Is there a hot key similar to ctrl+enter that can help move my cursor out of the quotations but not to the next line?
I often use Cmd-Right Arrow to move the the end of the line. I also make heavy use of Opt-Right Arrow and Opt-Left Arrow to move words at a time instead of characters.
My solution to this was to record my own macro; it moves the caret to the right, inserts a comma and then a space. I've mapped the macro to command and < (shift and comma). Activating the macro on your code results in:
mysql_connect('localhost', [cursor is here])