My problem is, when I comment out a line using Ctrl + /,
// comment
and then auto-format the code,
// comment
the comment will still contain whitespaces after the "//" that I wouldn't want to keep.
I've already checked the Settings>Editor>Java>Wrapping and Braces options, and also the other tabs.
Thanks in advance.
I have just solved this problem.
Code Style -> Java -> Code Generation
There is a "Comment Code" and deselect the "Line comment at first column"
Code Style -> Java -> Wrapping and Braces
There is a "Keep when reformatting" and deselect the "Comment at first column"
As follows
Code Generation
Wrapping and Braces
I think your problem can be solved.
To apply identation to a document press Ctrl + Alt + L (Option + Command + L in Mac)
But the only way, once you have few comments with that "problem", I guess is to replace ('// ' by '//') (Shortcut to replace: Ctrl + Shift + R)
Hope it hepls.
Related
I have a snippet of code I copied into my clipboard. Pasting it out looks like this. Where[tab] is an actual tab indent
[tab]<header id="masthead" class="site-header">
[tab][tab]<h1>
[tab][tab][tab]<h2>
[tab][tab][tab][tab]<h3>
[tab][tab][tab][tab][tab]<h4>;
I want to press an autohotkey to automatically normalize the code snippet. So if there's a [tab] on every line, remove it.
Then convert each [tab] into 2 spaces [**]
<header id="masthead" class="site-header">
**<h1>
****<h2>
******<h3>
********<h4>;
So the general workflow is:
Copy code to clipboard
Press an autohotkey
Paste the newly formatted contents
Pseudocode for autohotkey would look like this
Dig through every clipboard content line by line
If every item shares an equal number of [tab] spaces, remove them entirely
Line by line, convert [tab] to [**] 2 spaces
; convert each tab into 2 spaces:
clipboard =
(
<header id="masthead" class="site-header">
<h1>
<h2>
<h3>
<h4>;
)
clipboard := StrReplace(clipboard, A_Tab, A_Space A_Space)
https://autohotkey.com/docs/commands/StringReplace.htm
okay problem solved I have everything I want now. I took the other source code snippet here on autohotkey forum
F9::
clipboard := StrReplace(clipboard, A_Tab, A_Space A_Space)
position := RegExMatch(clipboard, "\S")
test := RegExReplace(clipboard, "m)^[ ]{" . position - 1 . "}")
clipboard := test
As a reference, need to highlight the full line on code snippet like so
So all I have to do now is:
Copy the full code
Press F9
Paste into my notetaking app (dynalist.io with codesnippet support)
It was not like this in version 1.5, but now that I updated my Android Studio to 2.1.1 whenever I generate a local variable with the Ctrl + Alt + V shortcut, the variable is generated with the keyword "final".
For example, let's say I have the following statements:
Object o = new Object();
o.toString();
Let's highlight the second line and press Ctrl + Alt + V and voila:
final String s = o.toString();
// ^ I'm talking about this.
How do I disable the auto-generaion of the keyword "final"?
This auto-insertion of final is highly annoying as I use this shortcut like every other minute and I have to delete the keyword because most of the time I don't need the variable to be final and would not like to keep my code unnecessarily wordy.
I don't know why you want to turn it off since it is good practice.
Here is how you can do that:
Please note this is NOT related to :paste / :nopaste and the clipboard. I'm talking about copying and pasting entirely within vim (d, y, p).
It is common to copy and paste a block of code from an outer block into an inner block. Unfortunately, the indentation still is at the level of the outer block and I have to indent it afterwards.
What I want to do is to go from:
function foo() {
}
var bar;
var bazz;
to
function foo() {
var bar;
var bazz;
}
In vim what I normally do is:
1) go to the line
2) switch to visual mode
3) highlight the rows
4) dd to delete the lines
5) move the cursor up
6) P to paste
7) enter visual mode
8) highlight the rows
9) >> to indent the lines
I want it to automatically indent to the correct location. It would be a much smoother workflow if I didn't need to re-highlight the rows and then indent them manually. In other words, eliminate steps 7-9.
Anybody know of a way to do this?
You can easily make this a keymap that does auto indenting as part of pasting.
For example,
nnoremap gp p`[v`]=
Breakdown:
p to paste text
`[v`] to selecte Pasted text
= to autoindent selected text
I came across this plugin.
https://github.com/sickill/vim-pasta
Looks like it does the same thing as ronakg mentioned above with some additional functionality.
I have a virtual keyboard created in RealBasic.
When I press letters, numbers I append it to a textfield all its ok but, how do I delete characters from that textfield from current cursor position when I press "Delete" button from virtual keyboard?
To append letters or numbers to the textfields I use:
TextField1.Text = TextField1.text + me.Caption //to append caption
TextField1.SelStart = Len(TextField1.text) // to move cursor at the end of string
Paul's solution works if you only plan to delete the last typed character.
But beware: If you let the user also move the cursor left and right, you have to delete the text at the position of the cursor, of course. And if you also allow the user to select text, then it's even more complicated.
I suggest that your virtual keyboard simply send the typed key to the system as if the user had pressed the key. That way, the TextEdit field will do everything for you.
To make this work, however, you need custom solutions for each OS platform you want to support.
Let me know which platforms you plan to support and I'll see what I can find. I have some code for OSX but not for Windows, yet.
Doing what Thomas said means:
dim n as String = TextField1.Text
n = newText.left(TextField1.selStart) + n.right(n.len - textField1.selStart - 1)
textField1.text = n
Just lop off the last character:
TextField1.Text = TextField1.Text.Left(TextField1.Len-1)
Basically,
It's inspired by Vim I want to use a key(e.g Alt, F1) combination(+I J K L) to map to Arrow Keys
What is already done in Autohotkey
Ralt & j::send{Left}
Ralt & k::send{Right}
...
Now I take Alt+I as up etc,which is pretty fine for me But the problem comes when you press
Ralt+Shift+j (Suppose to select the last charater)
Ralt+Ctrl+j (Suppose to move a caramel text)
These kind of combination would not work and it just get overrided to basic move cursor to left
Even if I use if/while statement with GetKeyState, it doesn't gonna work
if GetKeyState("Shift","P")
Ralt+j::send +{Left}
This kind of stuff didn't work
Any Ideas on that ?It would make coding very efficient without having to move the right hand.
Thanks in advance.
You are missing 2 things:
Must use a # symbol when doing a context sensitive hotkey
The bottom section of code is using a + instead of the & you used previously.
See the below modification:
RAlt & j:: Send {Left}
RAlt & k:: Send {Right}
#If GetKeyState("Shift","P")
RAlt & j:: Send +{Left}
RAlt & k:: Send +{Right}
; Close with #If to remove the context or simply start another '#If GetKeystate ....'