Just starting with Vim and I wondered – given a Sass block like this:
.thing {
width: 100%;
color: $color1;
.nested {
height: 1rem;
}
}
If my cursor is at the 'd' within 'width', what's the quickest way to visually select the entire rule set, selector, braces and all?
At present I am using 'Shift+}' to jump to the next blank line and then 'v' for visual and 'Shift+{' to select the prior block. Any better way?
You're close. As you're already using the { and } motions to the borders of the current paragraph, just use the related text object: Vip, where V starts (linewise, but you can also use v as this text object forces this) visual mode, and ip selects the inner paragraph.
Related
Using sublime text (3) I'd like to use this old fashioned kind of indentation (https://en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style):
if (a > 1)
{
printf("yay");
return;
}
but all I get from the settings is this:
if (a > 1)
{
printf("boo");
return;
}
is there a way to have the bracket auto indented as in my first example? I'm somewhat ok with having to push tab once myself to indent, but sublime text insists on adding another indentation after that so that the brackets no longer line up with the start of the printf statement.
I am hiding the character * by inserting GlyphProperty.null then calling setGlyphs(_:properties:characterIndexes:font:forGlyphRange:) inside layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:) as described in the answer in https://stackoverflow.com/a/57697139/9568961, it works but after a certain sequence of text editing, the cursor starts to misplace, as shown in the gif https://github.com/dzAtZJU/Demos/blob/master/cursor_misplace.GIF?raw=true
GIF Description: When the second line becomes qq, I try to move the cursor to the end of first line, but it move directly to the beginning. I then try to delete characters, then the cursor move to the end correctly.
The sample project is here https://github.com/dzAtZJU/HideText.
Is it a bug? Have anyone run into this? How can I work around this?
This is a year-old question, but for anyone struggling with the same problem, here's a solution.
My Markdown-like parser knows the ranges for both the line on which the cursor is now, and where it was previously. I'm calling hideAndShowMarkup whenever text view selection changes.
You need to invalidate current glyphs for both of the ranges, and then redraw them synchronously before updating insertion point. The most crucial step is invalidating layout for the range where you want to show Markdown symbols. Without that, your caret gets drawn into the wrong position.
Code is in Objective C, but should be easy to implement in Swift, too.
-(void)hideAndShowMarkup {
// Just for reference
Line* line = currentLine;
Line* prevLine = previouslySelectedLine;
[self.layoutManager invalidateGlyphsForCharacterRange:line.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateGlyphsForCharacterRange:prevLine.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateLayoutForCharacterRange:line.range actualCharacterRange:nil];
if (NSGraphicsContext.currentContext) {
[self.layoutManager drawGlyphsForGlyphRange:line.range atPoint:self.frame.origin];
[self.layoutManager drawGlyphsForGlyphRange:prevLine.range atPoint:self.frame.origin];
}
[self updateInsertionPointStateAndRestartTimer:NO];
}
Is there a way to select every media query and its contents using Sublime Text 3? For example I have a CSS file with lots of #media print queries, I'd like to select all of them AND the contents in one go.
#media print {
.app-contact-panel__heading,
.app-prose-scope h3 {
font-size: 18pt;
line-height: 1.15;
}
}
I know I can select one #media print and press CMD + D to select the next one. Or CTRL + CMD + D to select all #media print in the doc, but neither selects the properties as well?
Can anyone help?
One way to do this would be via a plugin. The following plugin highlights all the contents of those media queries that begin with #media print {
import sublime
import sublime_plugin
class HighlightMediaQueryCommand(sublime_plugin.TextCommand):
def run(self, edit):
# This finds all the regions that are #media print {
media_regions = self.view.find_all(r"#media print {")
# This will clear the current Selection object.
self.view.sel().clear()
# We now add the region corresponding to the opening bracket of each media print query.
for regions in media_regions:
self.view.sel().add(sublime.Region(regions.end(), regions.end()))
# Next, we move the selection to the end of the brackets.
self.view.run_command("move_to", { "to": "brackets" })
# Now that we have access to the closing bracket of each media print query, we can construct the Region object for all media print queries with their contents also.
for i, sel in enumerate(self.view.sel()):
self.view.sel().add(sublime.Region(media_regions[i].begin(), sel.end() + 1))
def is_enabled(self):
# Enable the command to work only in a CSS file.
return self.view.settings().get("syntax") == "Packages/CSS/CSS.sublime-syntax"
In order to use this plugin, you'll have to save this code in a .py file in the User directory (go to Preferences -> Browse Packages ... via the top menu). Once saved, you can use this plugin in either of the following ways :-
The quickest & easiest way is to just type view.run_command("highlight_media_query") in the sublime console input and pressing enter while you are in the desired css file (press ctrl/cmd + ` to access the console).
If you do this very often, you can bind it to a keyboard shortcut. To do that, you would have to create a .sublime-keymap file in the User directory (the keymap file name doesn't matter, though as a convention it's generally kept Default (os).sublime-keymap where os = Windows, Linux or OSX based on your OS). Then paste in the following (the key binding is of your choice, it can be anything as long as it doesn't conflict with existing ones):-
[
{ "keys": ["ctrl+alt+m"], "command": "highlight_media_query" }
]
Doing that & pressing the said key binding (you need to have opened the said css file), should now select all #media print queries.
I'm using Report Studio Version 10.2.2 and I have a question regarding value prompts.
I've got a report with a prompt page that works great. I set up a value prompt as a multi-select, check box group with default selections. I'd like to give a visual queue to the end user by changing the font color for the "Default Selections" to red.
How do you change the font color for specific display values in a value prompt?
JavaScript
You can add an HTML item before the value prompt:
<span id="MyList">
...and an HTML item after the value prompt...
</span>
<style>
.MyRedClass {
color: #ff0000;
font-weight: bold;
}
</style>
<script>
var s = document.getElementById("MyList");
var divCollection = s.getElementsByClassName("clsCheckBoxRow");
var isPositive = function(n) {
return n > 0;
}
for (var d = 0; d < divCollection.length; d++) {
switch (true) {
case isPositive(divCollection[d].innerHTML.indexOf("CORPORATION FOR PROFIT")):
case isPositive(divCollection[d].innerHTML.indexOf("CORPORATION NON PROFIT")):
case isPositive(divCollection[d].innerHTML.indexOf("INDIVIDUAL")):
divCollection[d].classList.add("MyRedClass");
break;
default:
break;
}
}
</script>
Problems:
You will need to maintain the list of default values in two places.
(Or you could abandon the Default selections property and use
JavaScript to set the defaults.)
My code looks for a class named
clsCheckBoxRow. That may not work for users using a different theme
(?). I don't know because I didn't bother testing.
If any of the default values match text that is in the HTML (other than the value -- unlikely), you'll need to make the search more specific. (like digging deeper into the DOM)
This may be challenging to upgrade to the Interactive Viewer in Cognos Analytics.
I have a YUI datatable and I am putting the following data in the table:
{key:"name", label:"name", editor: nameChoiceEditor},
{key:"group", label:"group", editor: groupChoiceEditor},
{key:"colony", label:"colony", width: 210, editor: colonyChoiceEditor},
...
Here the name column's width is set to the maximum length of characters entered for that name, and the same with group. colony's column width is set to 210 irrespective of the length of the data.
My problem is when the name column, having multiple words like "odaiah chitukuri", is showing in two lines like so:
odaiah
chitukuri
But when it is one word like "odaiahchitukuri" it is showing in a single line, meaning the column is adjusting to fit the word.
I should have the different words in sigle line. How to do that?
Have the 'breaking' spaces replace with non-breaking spaces.
Try the following:
Change:
{key:"colony", label:"colony", width: 210, editor: colonyChoiceEditor},
To:
{key:"colony", label:"colony", width: 210, editor: colonyChoiceEditor
formatter: function (el, oRecord, oColumn, oData) {
el.innerHTML = oData.replace(/ /g, ' ');
}
},
I'm not sure if your looking for a solution that will always keep the words on a single line.. but generally speaking the datatable does a good job of spacing out the columns correctly based on the content inside. In certain cases though I've definitely had to set the width of a column manually. Here is an example for a column with class appicon:
.yui-skin-sam .yui-dt tbody td.appicon {
width: 40px;
}
Bare in mind once the number of words in the column stretches past it's defined size, it will always move to the next line.
In datatable column define :
will be width:100
not width:"100px"
or width:"100"
or width:"100em"
Use width: 100
like that then its working fine for me