Keyboard shortcut to select current line in Xcode - xcode

Is there any way to select the text of the current line in Xcode? This would be equivalent to Cmd + l in Sublime or V in vim.

Actually you can just use the normal Mac-Shortcuts.
Beginning of Line
cmd + shift + >
Middle of Line
1. cmd + > (this brings you to the end of the line)
2. cmd + shift + < (selects everything to the left)
End of Line
cmd + shift + <
Hope this helps :)
Update
In Xcode 8, I have found the Select Line keyboard binding which you can set to cmd+l (that's L, not i) for instance to make Xcode select the line you're on right now when hitting that shortcut.

You can actually assign a key command to this. In Xcode under Preferences > Key Bindings > Text search for "Select Line" and assign it to you preferred key command (I also prefer command-l to match Sublime Text)

It's possible to select the line with ctrl + shift + a + e.
(a selects from cursor till the beginning of the line, while b selects from the cursor till the end of the line).
It's a bit long shortcut but can be useful if you end up needing only part of the line or the whole.
You can also split this into 2 steps:
ctrl + a to jump to the beginning of the line then use ctrl + shift + e to select till the end of the line.

Related

How do I comment out a block of code in Stan?

This feels like a duplicate question, but I can't find it anywhere here or elsewhere!
So, in R, you can comment out a block of code with Ctrl + Shift + C/Cmd + Shift + C. Does anyone know how to perform the equivalent action in Stan? All I know is that Stan uses // in place of R's #. I've tried Ctrl + Shift + //Cmd + Shift + /, to no avail.
Thanks so much for any help! :)
You can create a comment within your Stan code by using the following:
/* this is a comment block
as opposed to a single
line block */
Please see, https://mc-stan.org/docs/2_18/reference-manual/bracketed-comments.html

Syntax error ... Jython/Python

Hi I'm doing my first programming assignment (it's with Jython, i.e. Python using Java) and I've run into a syntax error on line 14 (bolded below). I've tried changing the variable to something less useful like "L" or "I" but it still gives the error. It's annoying because it makes no sense. I have tried indenting again and adding comments around it.
This is a program that outputs a picture of a soccer ball factory. It's as much as an artistic project as a comp sci project. So the printing looks complicated but is only like long checklist for building.
def prettyPic():
#building materials and parts
spacer = " "
ceiling_part = "-"
ball = "o"
wheel = ""
door_joint = "#"
left_half_arch = "/"
right_half_arch = "\\"
ladder = "\\"
wall = "|"
glass = (
#biox
**left_box = "u"
right_box = "u"**
#begin printing
print (spacer*30 + ceiling_part*30)
print (spacer*32 + wall*1) + (spacer*47 + wall*1)
#three balls, leaving space for drop
print (spacer*32 + wall*1) + (ball*27) + (wall*1)
#arches, not touching ceiling
etc, etc
The problem is in this line:
glass = (
This means that to glass variable, you assign tuple just like:
glass = (1, 2, 'some string')
Python interpreter searches for termination of just opened tuple but it finds only Python code that is not correct in this context.
Remove or comment out line with glass, or assign to glass variable some value.

Need Help - Simple Random Number Generator using Auto Hot Key Script

I've read the documentation for Auto Hot Key, but am new to writing scripts. I keep getting errors.
I want a very simple script - so when I use a hotkey CTRL-ALT-N - Autohotkey creates a random number that is:
3 Digits - Decimal - 8 Digits
With the very first digit of the first group being between 1 and 4.
The rest can be completely random.
Off the sample scripts I tried to edit one posted - but I am doing something wrong. If anyone could help it would be really appreciated!
The output should look like this: 314.99382028 The first number always between 1 and 4, the rest random, and decimal always the 4th character.
Then, it should just paste the number to where ever you currently are within windows - not pop up display.
Thanks for anyone who could take a quick look and help out.
Rocket
^!n:: ;<-- change this if you want a diff hotkey
Chars1 = 1234
Chars2 = 1234567890
Chars3 = .
str =
clipboard =
UpperRange = 3 ;<-- use all 3 character strings
len = 12 ;<-- number of characters in the number
; generate a new number
loop, %len%
{ random,x,1,%UpperRange% ;<-- selects the Character string
random,y,1,26 ;<-- selects the character in the string
if (x = 12) ; if numeric there are only 10 digits
}
{ random,y,1,10
StringMid,z,Chars%x%,1 ;<-- grab the selected letter
str = %str%%z% ;<-- and add it to the number string
}
clipboard = %str% ;<-- put the completed string on the clipboard
Clipwait ;<-- wait for the clipboard to accept the string`
AND THEN PASTE WHERE EVER MY CURSOR IS - Not sure how to do that.
Thanks so much for the help!
Rocket
This should do the job if I understood it correctly:
^!n::
SendInput, % "{LButton}" . RandomString(1,"1234") . RandomString(2) . "." . RandomString(8)
Return
RandomString(length,chars:="0123456789") {
charsCount := StrLen(chars)
Loop % length {
Random, num, 1, % StrLen(chars)
string .= SubStr(chars,num,1)
}
Return string
}
Since you have your answer on your clipboard, you could simply use:
Send, ^v
This will paste where your caret is, not your mouse cursor, so if you want to paste where your mouse cursor is, just add Click before....
Click
Sleep, 30
Send, ^v

how to block indent in codeblocks

consider the following code :
int n,m,group=1;
char ch;
n=getint(); //WANT TO BACKWARD INDENT IT
m=getint(); //WANT TO BACK WARD INDENT IT
if(m==10)
ch='p';
else
ch='n';
...........
...........
So how would we do it in code blocks ? for forward indent , we select the block and press TAB key but what about backward especially in case when we have a large block of code?
Just Select the block :
if want to forward indent it use tab key ...
for backward use shift + tab key .....

Sublime Text 3: How to select multiple words and paste them into a single line separated by commas?

When you select multiple words in Sublime (by holding down Ctrl) and paste them into a single place, by default each word is separated from the next by \n. I'd like to change that to a comma and, optionally, have quotes put around each word. I'm wondering if there's an easy way to do that. Any help is appreciated.
Here is what I would do with some build-in shortcuts:
somehow select the lines you just paste (eg. expand_selection_to_paragraph, which is mapable)
ctrl+shift+l to make them into multi-cursor
ctrl+j to join lines
move cursor to end of each selection by moving right, insert comma, which will be between each selection.
If you want to write a plugin to simplify it (and customise to your exact need). Here is a very crude one I use to make a selection into a python list object. Feel free to modify and map to a key.
import sublime, sublime_plugin
class PythonListifyCommand(sublime_plugin.TextCommand):
"""Change a selected text into a Python list structure.
Basically this is done by replacing space, comma, tab with comma.
Then Python list brackets are attached to both start and end to make
a Python list.
If ther are multiple selections, then multiple lists will be created.
If any selection is of zero length, then that particular line will
be listified. There will always be a comma at the end of each line,
this is to make sure multiple line list can connect up. Python does
not mind extra comma at the end of a list inside bracket.
"""
def listify(self,line):
import re
no_leading = re.sub('^[ ,\t]+','',line)
no_leading = re.sub('\n[ ,\t]+','\n',no_leading)
in_line = re.sub('[ ,\t]+',',',no_leading)
end_line_comma = re.sub('\n',',\n',in_line)
return end_line_comma
def run(self, edit):
sel = self.view.sel()
view = self.view
for s in sel:
if s.a == s.b:
r = view.line(s)
else:
r = s
rep = '[' + self.listify(view.substr(r)) + ']'
if rep[-1] is ']' and rep[-2] is '\n':
rep = rep[:-2] + ']\n'
view.replace(edit, r, rep)

Resources