Preserve Case Replace in Sublime Text 3 - replace

From having done a bit of googling on this it seems that it is or at least was possible to do this with Sublime Text. I have seen multiple references to a preserve case button in the find and replace pane which looks like 2 rounded squares superimposed on each other.
However, I can't find this at all in my version of Sublime Text 3 (on Mavericks)...
Also I checked preferences to see if this option was somehow turned off but the only reference I could find to it was:
{ "keys": ["super+alt+a"], "command": "toggle_preserve_case", "context":
[
{ "key": "setting.is_widget", "operator": "equal", "operand": true }
]
},
in the default key map file...
Here is a screenshot of my find and replace pane:

In the latest Sublime 3 build (3059) there is a dedicated icon in the replace dialog to preserve the case. When toggling it and using the input shown in the screenshot, the following input string will be converted to the following output:
Input: "Xhis is my xest."
Output: "This is my test."

It's not exactly an answer to your almost 1.5 years old question, but maybe you (or somebody else) find(s) the following useful:
I wrote a ST package which includes a feature to preserve the case while editing multiple selections. It even preserves cases with separators like snake_case, dash-case, dot.case etc.
It is called MultiEditUtils. Here you can see the described feature.

Looks like it might have been a glitch in ST3 that was causing confusion.
I noticed that the shortcut key combo for replace has never worked for some reason and also that selecting replace from the find menu opened the find in file pane as opposed to the regular find and replace pane (where the preserve case button is). I only realised this after installing the soda theme for ST3 which showed the preserve case button in a screenshot.
Strangely, when I reverted to the default theme, the find > replace menu now works as it should and I found that the keyboard shortcut was being causght by another program which was why it didn't work...

Related

Kate Text Editor regexp for CNC code alteration on PC

When using some CAM software, the CNC code is usually generated properly with spaces.
But for example when moved to "Citizen Cincom L20" machine via USB or network and edited there it lose spaces and also lose semicolons while preserving new lines which does work as semicolons anyway.
But since editing of CNC program happens in 3 places: CAM Software(ESPRIT in this case), CNC machine controller and also via text editor on the computer as postprocessor in ESPRIT is garbage.I've come up with this regex
([0-9]{1,2})([A-Z])
\1 \2
so
G1G99X5.4Z-.5F.12
Becomes
G1 G99 X5.4 Z-.5 F.12
that works in Kate to space everything back again for clearer reviwing of code. The only issue about it is that I need to do that manually for every file and I would like to automate it, preferably via Kate, so it would happen upon opening any ????.PRG plain text files.
But I do not exactly know how such happening should be called is it like macro or what ?
I'm looking for some suggestions to accomplish this. Or maybe some alternative solutions
First, go to View -> Tool Views -> Show Search and Replace. You will see
Make sure you:
Enable {} regex option on the right as you are using a regex
Enable "AB" option on the right that enables case sensitive matching
Select In Folder value from the dropdown on the right
Fill out the regex, replacement, Folder and the Filter fields with the appropriate values
Click Search button.
You will see the results in a separate pane and Replace / Replace Checked buttons will become enabled.
Review the replacements and click Replace Checked:
Then you may check the updated file contents, and if you are satisifed with the results, use Save All, also by pressing CTRL+L.

AWS console search in array

I am looking for a string that I can paste into AWS search(searching volumes for example) in browser so I can look for volume names/id's either like "foo" or like "bar", so in essence "if in array" type of search.
I tried multiple approaches and fail on every one. Only thing that I can do is paste my string, hit enter, paste another one, hit enter, its feasible for 2 strings but not for 10.
TL;DR: \bFOO|\bBAR
If you click the "?" button in the search field (at least in EC2) you get a "search help" view describing advanced usages of the search bar:
This help page shows that you can use regular expressions. This one should work for your use case: \bFOO|\bBAR
Help window screenshot for reference:

IPython Notebook keyboard shortcut search for text

Is there a keyboard shortcut to search for text in an IPython Notebook?
I looked under Help | Keyboard shortcuts and there are lots of cool shortcuts but none for searching for text?
The notebook is running in FireFox on Ubuntu.
There is a find-and-replace command in Jupyter. It's key binding is F (command mode):
Of course you can find text with the browser's functionality, (I find it sometimes better), but the command in Jupyter is also very useful. I use a lot that function Replace in selected cells when I copy-paste a bunch of code and then change variables or something like that:
(Note: You can launch the Command Palette with shift+ctrl+P, and browse or run other commands)
Enter Command Mode by pressing esc, followed by find and replace key binding f, so
esc then f
Take the User Interface Tour (Help Menu) if you haven't already
As of Jupyter Lab v1.0.2 the CTRL+F twice press trick described in my comment above doesn't seem to work anymore.
I found the internal search functionality of jupyter lab pretty annoying, since it only searches in the current cell. I wanted to directly access the native browser search with CTRL+F.
To disable jupyter lab search function (and use browser search instead):
open Settings\Advanced Settings Editor
add the following to User Preferencec:
{
"shortcuts": [
{
"command": "documentsearch:start",
"keys": [
"Accel F"
],
"selector": ".jp-mod-searchable",
"disabled": true
}
]
}
This will override the System Default, with "disabled": true added, and enables Browser CTRL+F in all Jupyter Lab instances.
Select the cell(s) in which you want to replace.
Then just click outside those cells
Press f.
You are done!
:Embarassed: "Running in" means use the browser "find text on this page" shortcut.
Firefox shortcut for this is ctrl - F.

How to change indentation mode in Atom?

I haven't been able to figure this out yet. Atom seems to use spaces as the default indentation mode. I prefer to have tabs instead though. Sublime Text has built in functionality for switching and converting indentation.
Anyone found out how to change the indentation mode of Atom?
Some screenshots from Sublime Text:
See Soft Tabs and Tab Length under Settings > Editor Settings.
To toggle indentation modes quickly you can use Ctrl-Shift-P and search for Editor: Toggle Soft Tabs.
Go to File -> Settings
There are 3 different options here.
Soft Tabs
Tab Length
Tab Type
I did some testing and have come to these conclusions about what each one does.
Soft Tabs - Enabling this means it will use spaces by default (i.e. for new files).
Tab Length - How wide the tab character displays, or how many spaces are inserted for a tab if soft tabs is enabled.
Tab Type - This determines the indentation mode to use for existing files. If you set it to auto it will use the existing indentation (tabs or spaces). If you set it to soft or hard, it will force spaces or tabs regardless of the existing indentation. Best to leave this on auto.
Note: Soft = spaces, hard = tab
Add this to your ~/.atom/config.cson
editor:
tabLength: 4
OS X:
Go to Atom -> prefrences or CMD + ,
Scroll down and select "Tab Length" that you prefer.
You could try going to "Atom > Preferences > Editor" and set Tab length to 4.
This is for mac. For windows you will have to find the appropriate menu.
Adding #Manbroski answer here that worked for me:
try Ctrl-Shift-P Editor: Toggle Soft Tabs
Late to the party, but a clean way to do this on a per-project basis, is to add a .editorconfig file to the root of the project. Saves you from having to change Atom's settings when you're working on several projects simultaneously.
This is a sample of a very basic setup I'm currently using. Works for Atom, ST, etc...
http://editorconfig.org/
# Automatically add new line to end of all files on save.
[*]
insert_final_newline = true
# 2 space indentation for SASS/CSS
[*.{scss,sass,css}]
indent_style = space
indent_size = 2
# Set all JS to tab => space*2
[js/**.js]
indent_style = space
indent_size = 2
This is built into core: See Settings ⇒ Tab Type and choose auto:
When set to "auto", the editor auto-detects the tab type based on the contents of the buffer (it uses the first leading whitespace on a non-comment line), or uses the value of the Soft Tabs config setting if auto-detection fails.
You may also want to take a look at the Auto Detect Indentation package. From the docs:
Automatically detect indentation of opened files. It looks at each opened file and sets file specific tab settings (hard/soft tabs, tab length) based on the content of the file instead of always using the editor defaults.
You might have atom configured to use 4 spaces for tabs but open a rails project which defaults to 2 spaces. Without this package, you would have to change your tabstop settings globally or risk having inconsistent lead spacing in your files.
I just had the same problem, and none of the suggestions above worked. Finally I tried unchecking "Atomic soft tabs" in the Editor Settings menu, which worked.
If you are using the version 1.21.1:
Click on Packages / Settings View / Open
Select "Editor" on the left side panel
Scrool down until you see "Tab Length"
Edit the value. I like to set it to 4.
Now, just close the active tab pane and you are done.
Tab Control gives nice control in a similar manner to that described in your question.
Also nice, for JavaScript developers, is ESLint Tab Length for using ESLint config.
Or if you're using an .editorconfig for defining project-specific indentation rules, there is EditorConfig
If you're using Babel you may also want to make sure to update your "Language Babel" package. For me, even though I had the Tab Length set to 2 in my core editor settings, the Same setting in the Language Babel config was overriding it with 4.
Atom -> Preferences -> Packages -> (Search for Babel) -> Grammar -> Tab Length
Make sure the appropriate Grammar, There's "Babel ES6 Javascript Grammar", "language-babel-extension Grammar" as well as "Regular Expression". You probably want to update all of them to be consistent.
If global tab/spaces indentation settings no longer fit your needs (I.E. you find yourself working with legacy codebases with varied indentation formats, and you need to quickly switch between them, and the auto-detect isn't working) you might try the tab-control plugin, which sort of duplicates the functionality of the menu in your screenshot.
When Atom auto-indent-detection got it hopelessly wrong and refused to let me type a literal Tab character, I eventually found the 'Force-Tab' extension - which gave me back control.
I wanted to keep shift-tab for outdenting, so set ctrl-tab to insert a hard tab. In my keymap I added:
'atom-text-editor':
'ctrl-tab': 'force-tab:insert-actual-tab'
Changing language-specific configuration
I changed the default tab settings, and it still did not impact when I was editing my files, which were Python files. It also did not change when I modified the "*" setting in ~/.atom/config.cson . I don't have a good explanation for either of those.
However, when I added the following to my config.cson, I was able to change the tab in my Python files to 2 spaces:
'.source.python':
editor:
tabLength: 2
Thanks to this resource for the solution: Tab key not respecting tab length
All of the most popular answers on here are all great answers and will turn on spaces for tabs, but they are all missing one thing. How to apply the spaces instead of tabs to existing code.
To do this simply select all the code you want to format, then go to Edit->Lines->Auto Indent and it will fix everything selected.
Alternatively, you can just select all the code you want to format, then use Ctrl Shift P and search for Auto Indent. Just click it in the search results and it will fix everything selected.
Yet another answer: If you are using Atom Beautify note that it has its own settings to determine the "Indent Char".

How can I have HTML tab expansion in ST2 w/ Emmet inside Handlebars templates(emberjs)?

Okay, so I'm using Sublime Text 2 with Emmet. But "Tab" expansion of HTML snippets doesn't work inside a script because of the scope.
Example:
In HTML, I can type "h1" and then hit tab, and it will generate <h1></h1>
When using Ember.js, and more specifically Handlebars, it doesn't work.
<script type="text/x-handlebars">
h1
</script>
Pressing tab after that "h1" doesn't expand it because it's inside a script; Emmet turns this off. I can press Ctrl+E, which is the "expand anywhere" hotkey, and that works just fine. However, that is uncomfortable and prone to missing and hitting things like Ctrl+S or Ctrl+D which have undesired effects.
So, how can I change this?
I tweeted at the developer, and got a reply, https://twitter.com/chikuyonok/status/398708331969540096
But couldn't understand what to do.
In my opinion, he meant that you needed to change the scope for expand_abbreviation_by_tab. Please open Default (Windows/Linux/OSX).sublime-keymap, search expand_abbreviation_by_tab, add source.js in operand list. It makes it take affect in JavaScript file.
"command": "expand_abbreviation_by_tab",
"context": [
{
"operand": "source.js, source.css, source.sass, source.less, source.scss, source.stylus, text.xml, text.html - source, text.haml, text.scala.html, source string",
"operator": "equal",
"match_all": true,
"key": "selector"
},
I'll add further clarification here since this took me a while to find out:
Copy all of the two keys: ["tab"] objects from the Emmet default keybindings
Paste them into your User keybindings
Add source.handlebars as an additional operand to each of the two contexts.
This also works with Ember Syntax Highlighting when the handlebars files are being interpreted as Glimmer files.