Powershell ISE – change indent/tab size + keep tabs

Anyway to change indent/tab size in Powershell ISE?
Something simple like in Visual studio IDE:
Tab size 2
Indent size 2
Keep tabs

Figured I'd share the changes I made to NoSimDash's above code. I actually wrote this not long after he posted his reply, but decided not to post it after I settled on taking the cheap, hacky timer route. (Originally I was looking to have the process triggered
by an event when the user changed tabs)
Anyways, over the last two years it's been pretty stable, so I thought I'd share on the off-chance that someone goes looking for this functionality again.
$psISE.Options.ShowOutlining = $true
$psISE.Options.ShowDefaultSnippets = $true
$psISE.Options.ShowIntellisenseInScriptPane = $true
$psISE.Options.ShowIntellisenseInConsolePane = $true
Set-Variable -Option AllScope -Name OptionSetter -Value (&{
$ClassName = 'IndentFixer'
$Namespace = 'ISEHijack'
Add-Type @"
internal class _Option<TValue>
public _Option(string key, TValue value)
Key = key;
Value = value;
public Object[] Params { get { return new object[] { Key, Value }; } }
public string Key { get; private set; }
public TValue Value { get; private set; }
internal static object[] Opt<TVal>(string key, TVal value)
return new _Option<TVal>(key, value).Params;
internal static readonly object[][] NewOpts = {
Opt<bool>("Adornments/HighlightCurrentLine/Enable", false),
Opt<int>("Tabs/TabSize", 4),
Opt<int>("Tabs/IndentSize", 4),
Opt<bool>("Tabs/ConvertTabsToSpaces", false),
Opt<bool>("TextView/UseVirtualSpace", false),
Opt<bool>("TextView/UseVisibleWhitespace", true)
internal void SetOpts()
foreach(object[] args in NewOpts) {
Setter.Invoke(Options, args);
public MethodInfo Setter { get; set; }
public object Options { get; set; }
public Dispatcher EditorDispatcher { get; set; }
public List<Action> Actions { get; private set; }
public ${ClassName}()
Actions = new List<Action>();
Actions.Add(SetOpts);
public void Dispatch(Dispatcher dispatcher)
DispatcherFrame frame = new DispatcherFrame();
dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback(ExitFrames), frame);
Dispatcher.PushFrame(frame);
private object ExitFrames(object f){
DispatcherFrame frame = ((DispatcherFrame)f);
// foreach(Action action in Actions) {
// action.Invoke();
// Actions.Clear();
foreach(object[] args in NewOpts) {
Setter.Invoke(Options, args);
frame.Continue = false;
return null;
"@ -Name $ClassName `
-NameSpace $Namespace `
-UsingNamespace System.Windows.Forms,System.Windows.Threading,System.Reflection,Microsoft.VisualStudio.Text.EditorOptions.Implementation,System.Collections.Generic `
-ReferencedAssemblies WindowsBase,System.Windows.Forms,Microsoft.PowerShell.Editor
return `
"${Namespace}.${ClassName}" |
Add-Member -Type NoteProperty -Name Namespace -Value $Namespace -Passthru |
Add-Member -Type NoteProperty -Name ClassName -Value $ClassName -Passthru
[System.Reflection.BindingFlags] $NonPublicFlags = [System.Reflection.BindingFlags] 'NonPublic,Instance'
filter Expand-Property
PARAM(
[Alias('Property')]
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory, Position=0)]
[String] $Name
$_ | Select-Object -ExpandProperty $Name | Write-Output
function Get-IsePrefs
PARAM(
[Parameter(Mandatory, Position=1)]
[ValidateNotNullOrEmpty()]
[string] $Key
$oEditor = $psISE.CurrentFile.Editor
$tEditor = $oEditor.GetType()
$tEditor.GetProperty('EditorOperations', $NonPublicFlags).GetMethod.Invoke($oEditor, $null).Options | `
Expand-Property GlobalOptions | `
Expand-Property SupportedOptions | `
Select-Object -Property Key,ValueType,DefaultValue | `
Write-Output
function Comment-Selection
$output = ''
$psISE.CurrentFile.Editor.SelectedText.Split("`n") | ForEach-Object -Process { $output += "# " + [string]$_ + "`n" }
$psISE.CurrentFile.Editor.InsertText($output)
function Fix-EditorIndentation
PARAM(
[Alias('ISEEditor')][ValidateNotNull()]
[Parameter(Mandatory, ValueFromPipeline, Position=1)]
[Microsoft.PowerShell.Host.ISE.ISEEditor]
$Editor
$EditorType = $Editor.GetType()
$SetterInstance = New-Object -TypeName $OptionSetter
$SetterInstance.Options = $EditorType.GetProperty('EditorOperations', $NonPublicFlags).GetMethod.Invoke($Editor, $null).Options
$Dispatcher = $EditorType.GetProperty('EditorViewHost', $NonPublicFlags).GetMethod.Invoke($Editor, $null).Dispatcher
$SetterInstance.Setter = $SetterInstance.Options.GetType().GetMethod('SetOptionValue', [type[]]@([string],[object]))
$SetterInstance.Dispatch($Dispatcher)
function Fix-IseIndentation
[Microsoft.Windows.PowerShell.Gui.Internal.MainWindow] $ISEWindow = (Get-Host | Select-Object -ExpandProperty PrivateData | Select-Object -ExpandProperty Window)
[Microsoft.Windows.PowerShell.Gui.Internal.RunspaceTabControl] $RSTabCtrl = $ISEWindow.Content[0].Children[2]
[Microsoft.PowerShell.Host.ISE.PowerShellTab] $PSTab = $RSTabCtrl.Items[0]
$PSTab.Files | Select-Object -ExpandProperty Editor | Fix-EditorIndentation
function Invoke-ISEFunction
PARAM(
[Parameter(Mandatory, Position=1)]
[Action] $ScriptBlock
$ISEWindow = $(Get-Host | Select-Object -ExpandProperty PrivateData | Select-Object -ExpandProperty Window)
return $ISEWindow.Dispatcher.Invoke($ScriptBlock)
function Fix-IndentationForAll
$psISE.PowerShellTabs | Select-Object -ExpandProperty 'Files' | Select-Object -ExpandProperty 'Editor' | Fix-EditorIndentation
# Startup
function New-Timer
PARAM(
[Alias('Handler')]
[Parameter(Position=0, Mandatory=$true)]
$Action,
[Double]
[Parameter(Mandatory=$false)]
$Interval = 50,
[Boolean]
[Parameter(Mandatory=$false)]
$AutoReset = $true
[System.Timers.Timer] $oTimer = New-Object -TypeName System.Timers.Timer($Interval)
$ElapsedEvent = Register-ObjectEvent -InputObject $oTimer -EventName 'Elapsed' -Action $Action
$oTimer.AutoReset = $AutoReset
return $oTimer
$(New-Timer {
Fix-IndentationForAll
} -Interval 100 -AutoReset $true).Start()

Similar Messages

  • How to change the font size from tabs ???

    Hi
    I found a tip to change the CSS in the apache directory in the forum here.
    but i can´t find the directory on my hard disk/oracle directory
    i got this version installed:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    can i change the font size of tabs/regions etc in any other way??

    Hi,
    The font size is defined by the style class used for the tab cells (tabs are normally created as cells in a table).
    To do this, the simplest solution may be to edit the page template:
    1 - Go to Shared Components/Templates
    2 - Select the page template(s) that you are using (you will have to do this for each template that you've used that uses tabs)
    3 - Scroll down to "Standard Tab Attributes" - you'll see two sections: Current Tab and Non Current Standard Tab.
    In Current Tab, you'll have something like:
    &lt;a href="#TAB_LINK#" class="t12standardtabcurrent"&gt;#TAB_LABEL#&lt;/a&gt;
    In Non Current Standard Tab, you'll have something like:
    &lt;a href="#TAB_LINK#" class="t12standardtabnoncurrent"&gt;#TAB_LABEL#&lt;/a&gt;
    After the class="...." attribute add in style="font-size:12px" (use whatever px value you want)
    4 - You should repeat the process for Current Parent Tab and Non Current Parent Tab as these contain the same settings
    5 - Apply your changes
    Regards
    Andy

  • JTabbed pane, adjusting tab size where tab name is shown

    Hello,
    Does any one know if it is possible to adjust the size of a the tab which displays the name of the tab on a JTabbedPane? I know it will adjust horizontally automatically based on the String you provide for the title, what I want to do it adjust it vertically also. I tried using "\n Main Menu\n" as the title thinking that it would add two extra blank lines but this didn't work. Nothing in the API looks like it will do what I want either. Can anyone tell me if this is possible or if there is a work around?
    Thanks
    Mike

    I've never tried it on a JTabbedPane but check out the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/html.html]Using HTML in Swing Compoennts.

  • Reopen last used tabs in Powershell ISE

    Hi Scripting Guys
    I use a lot of tabs in Powershell ISE console in my work, as an Administrator, and every time I close the ISE I need to reopen every tabs that I used before. So my question is:
    When I open Powershell ISE can it automatically reopen last tabs, that I used? Can Powershell ISE remember that last used tabs like IE can remember last open browser session?
    Best regards,
    Thorkell

    Hi,
    I do this by killing the ISE process with process explorer instead of closing the window. The next time you open the ISE it will note that it didn't shut down properly and will reopen the tabs you had open previously.
    I'm not aware of a graceful way to do this though.
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)
    kill $PID -Force
    I've done this a few times to keep my tabs when I open up ISE another time. :)
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Tab size -- where to set?

    Hello,
    I have been trying to find where in the code editor options I can set the tab size. There is one for the SQL Formatter, but there does not seem to be one for the code editor. If there is one, where can I find it?
    Either there should be a way to set the tab size for the code editor, or the code editor should respect the tab size and tab policy set in the SQL Formatter options.
    Regards,
    Janus Christensen

    Bringing this one back up with some other additions.
    There's, as said, no ability to set the tab size/length. SQL Developer also doesn't have options in relation to tabs like using tabs for auto-indent and it always replaces a press of the tab-key with a double-space. All of my present code uses tabs for indentation. IMO, it's easier to modify with tabs and if spaces start getting used in the files for tabs now then any other editor that supports tab length is going to generate odd formatting. (Lines that were indented with tabs will have the length of whatever it's set for in that environment while lines that use spaces will still have the 8 spaces).
    Right now my work around is to turn off auto-indent and copy/paste a tab character in order to be able to use tabs for indentation.

  • JTabbedPane Tab Size & Spacing

    I have set up a JTabbedPane and have put icons in instead of text for the tabs, the icons I've designed are supposed to take the place of the tab look, I already have the tabs transparent. I was wondering if anyone could help me with tab size and tab spacing because my custom tabs are WAY too far apart. Thanks in advance.

    I figured it out, I made a custom UI class that extends BasicTabbedUI and set the constraints that I desired.

  • How can I change the page size of a pdf so i can view it on my iphone more clearly?

    How can I change the page size of a pdf so i can view it on my iphone more clearly?

    I think there may be more to this question than you say.
    If your PDF page is say, 8 x 12 inches, and you found a way to scale it to 25%, changing it to 2 x 3 inch, shrinking everything on the page to quarter size - wouldn't it look exactly the same on the iPhone? It's just going to be the same as zooming.
    Or were you hoping for something more like in Word, where changing the page size keeps everything the same size and spreads it over more pages? That isn't something you can do.

  • Set indention / tab size in Oracle SQL Developer

    I've been poking around for an hour. Can't figure this out.
    Where, either on the app's UI or in the "product-preferences.xml" file, can I change SQL Developer's indention (tab) size to 3? My organization uses PowerBuilder, and when I copy+paste our PB SQL (which uses leading tabs) into Oracle SQL Developer, it looks like crap. It would really help if I could change the code editor to a tab size equivalent to three spaces.
    And no, we can’t use spaces. :-)
    Thanks!
    (maybe SQL Developer 2 could have a tab size field in “Preferences”)

    In 1.5.x, it's under Preferences - Database - SQL Formatter - Alignment and Indentation .
    However, at least in the current 1.5.3, a bug ignores the tab preferences completely, so you're stuck with the 2 spaces. If you can't wait until this gets fixed (with luck in the upcoming 1.5.4 or else maybe by 2.0), revert to an earlier version.
    Regards,
    K.

  • Trying to change the Tab size of SQL Server 2008 R2 ?

    Been trying to change the size of the tab but it just doesnt change!
    Went to Tools-Options-Text Editor-Transact-SQL
    From 2 to 1. 
    Any ideas? 

    Hi Shavendra,
    The Options dialog box lets you change the default behavior of the Database Engine Query Editor while you are programming Transact-SQL scripts. To display these settings, click Options on the Tools menu, expand the Text Editor folder, expand the Transact-SQL
    subfolder and then click Tabs.
    Tab size: Sets the distance in spaces between tab stops. The default is four spaces.
    Reference: http://msdn.microsoft.com/en-us/library/bb895215.aspx.
    Thanks,
    Maggie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.

  • Unwanted image size change when moving a image it's Tab to another Tab in CC 2014

    Hi, I opened a photo with a physical size 16"w 36"h. Since role paper comes in 24" width, I proceeded with expanding the canvas size to 24"w, height is unchanged at 36". Then I opened two photos in separate tabs in Photoshop, changed the image sizes to 8"w x 12"h. One Photo is from a 36megapixel camera and the other from a 16megapixel camera. Created two layers in the 24x36 image tab. Then I proceeded to copy each photo and paste in each of those layers (one image per layer in case you’re wondering). The problem is as follows, the copied images are larger when pasted into those layers, 10” wide and not 8”, 14”high and not 12”. Thinking maybe the canvas size had something to do with this, so I made that change. The result was the same, larger when pasted into those layers, 10” wide and not 8”, 14”high and not 12”. Could someone please advise what I’ve done wrong? Note, the ruler bars are visible. Thanks

    When you bring one image into another, it is the pixel size that counts.  The physical size of the source image becomes irrelevant.

  • Change Text Tab size in VA02

    Dear Experts,
    Is there a way to change the default size of Txt type inside Texts tab in Transaction VA02?
    (GoTo-> Header->Texts, Txt ty.)
    Thanks,
    Sagit.

    Please reference and follow the following documents (already mentioned in the note referenced above).
    Note: 269129.1 - How to Implement Printing for Oracle Applications: Getting Started
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=269129.1
    Note: 269129.1 - Building a Printer Initialization String for Oracle Applications
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=269129.1
    Note: 269129.1 - How to Test an Initialization String Outside of Oracle Applications
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=269129.1

  • How to change the font size of Text Box  Properties Appearance tab into 2 decimal digit.

    How to change the font size of Text Box  Properties Appearance tab into 2 decimal digit. I am uanble to modify it to 5.38 pt for example. Its only allowing to 1 decimal place.

    Click on each field and the choose Properties from either File menu (or if on Mac hold dow mouse button until context menu appears choose properties)
    go to Font
    choose desired size and type font,you can choose to make this the default.
    Do this with each field.
    Or if you have a lot of fields:
    while one is selected select all of them
    then go to fonts in properties
    change Font and size and make default.

  • How can I keep tabs on the file size when importing from the Event Library into a Project? I want to ensure the movie will fit onto a 4.7Gb disc?

    How can I keep tabs on the file size when importing from the Event Library into a Project? I want to ensure the movie will fit onto a 4.7Gb disc?

    iDVD does not care about file sizes, as it compresses the file to the standard DVD format of mpeg2.
    It only cares about length i.e. max 2 hours including titles etc.
    iDVD encoding settings:
    http://docs.info.apple.com/article.html?path=iDVD/7.0/en/11417.html
    Short version:
    Best Performance is for videos of up to 60 minutes
    Best Quality is for videos of up to 120 minutes
    Professional Quality is also for up to 120 minutes but even higher quality (and takes much longer)
    Professional Quality: The Professional Quality option uses advanced technology to encode your video, resulting in the best quality of video possible on your burned DVD. You can select this option regardless of your project’s duration (up to 2 hours of video for a single-layer disc and 4 hours for a double-layer disc). Because Professional Quality encoding is time-consuming (requiring about twice as much time to encode a project as the High Quality option, for example) choose it only if you are not concerned abo
    In both cases the maximum length includes titles, transitions and effects etc. Allow about 15 minutes for these.
    You can use the amount of video in your project as a rough determination of which method to choose. If your project has an hour or less of video (for a single-layer disc), choose Best Performance. If it has between 1 and 2 hours of video (for a single-layer disc), choose High Quality. If you want the best possible encoding quality for projects that are up to 2 hours (for a single-layer disc), choose Professional Quality. This option takes about twice as long as the High Quality option, so select it only if time is not an issue for you.
    Use the Capacity meter in the Project Info window (choose Project > Project Info) to determine how many minutes of video your project contains.
    NOTE: With the Best Performance setting, you can turn background encoding off by choosing Advanced > “Encode in Background.” The checkmark is removed to show it’s no longer selected. Turning off background encoding can help performance if your system seems sluggish.
    And whilst checking these settings in iDVD Preferences, make sure that the settings for NTSC/PAL and DV/DV Widescreen are also what you want.
    http://support.apple.com/kb/HT1502?viewlocale=en_US

  • How to change tab size on Jtabbedpane?

    Hi,guys,
    I want to set an icon on each tab,so my code is as follows:
    ImageIcon projectIcon= createImageIcon("bleumbuddy/workorder-tab2-active.gif");
    jTabbedPane1.addTab("",projectIcon,jPanel7);
    But the tab size is bigger than the img's size,How can I change it to the same as the image?
    thanx a lot .
    Best Regards
    Dragon

    Hi,guys,
    I want to set an icon on each tab,so my code is as follows:
    ImageIcon projectIcon= createImageIcon("bleumbuddy/workorder-tab2-active.gif");
    jTabbedPane1.addTab("",projectIcon,jPanel7);
    But the tab size is bigger than the img's size,How can I change it to the same as the image?
    thanx a lot .
    Best Regards
    Dragon

  • WAD template issue:Change Font Size of Tab page in a tab strip container

    Hi Gurus,
    Is it possible to change the font size and face of a "tab" in a tabstip container.
    For example: I have a Tab strip container with 3 tabs:
          Tab1 : North Region
          Tab2: South Region
          Tab3: Central Region.
    When we name the tabs as above, it displays in a default font size and font face in the output while executing the WAD template. I want to increase the font size of say " North Region" Tab so that it appears bigger.
    Can some one guide me as to how this can be achieved.
    Regards,
    Sandeep

    Hi Benni,
    Could you please explain where i am supposed to enter the code mentioned by you "<style type="text/css" >.urBtnStd </style>"
    The XHTML code looks as below-->
    html
           head
                <title >BEx Web Application</title>
                meta http-equiv="Content-Type" content="text/html; charset=utf-8"
                 head
            body
                <bi:QUERY_VIEW_DATA_PROVIDER name="DP_1" >
                    <bi:INITIAL_STATE type="CHOICE" value="QUERY" >
                        <bi:QUERY value="RBEI_BICM_HR_RRF_PERIOD" />
                    </bi:INITIAL_STATE>
                </bi:QUERY_VIEW_DATA_PROVIDER>
                <bi:TEMPLATE_PARAMETERS name="TEMPLATE_PARAMETERS" >
                    <bi:SYSTEM_MESSAGES_VISIBLE type="CHOICE" value="X" text="" />
                    <bi:VARIABLE_SCREEN value="" />
                    <bi:MELT_VARIABLES value="" />
                    <bi:HAS_MAIN_TEMPLATE_OBJECT type="CHOICE" value="" />
                    <bi:WEB_TEMPLATE_ACTIONS type="COMPOSITE" >
                        <bi:ACTION_BEFORE_FIRST_RENDERING type="COMPOSITE" />
                    </bi:WEB_TEMPLATE_ACTIONS>
                </bi:TEMPLATE_PARAMETERS>
                <p >
                    <br />
                </p>
                <bi:TABSTRIP_CONTAINER_ITEM name="TABSTRIP_CONTAINER_ITEM_1" designwidth="600" designheight="600" >
                    <bi:TABPANEL_LIST type="ORDEREDLIST" >
                        <bi:TABPANEL type="COMPOSITE" index="1" >
                            <bi:CAPTION value="North Region" />
                        </bi:TABPANEL>
                    </bi:TABPANEL_LIST>
                </bi:TABSTRIP_CONTAINER_ITEM>
                <br />
                <br />
            </body>
    html
    Thanks,
    Sandeep
    Edited by: Sandeep Rupert Saldanha on Feb 17, 2010 10:53 AM

Maybe you are looking for