Beginner's TextMate Question - textmate

So I'm coming from the world of Visual Studio wherein which I have "intellisense" and certain keyboard shortcuts (thanks also in large part to ReSharper). I am transitioning to the Mac and have a copy of TextMate.
How do you get it to automatically place a closing HTML tag when you create a new one? Is this a "bundle" and if so how do I get it to work.
Sorry, beginner's question

Assuming you are in HTML mode... (look at the status bar at the bottom)...
Type a word then press ctrl <
That will use the word to create open and close tags for the word (e.g. table)
table^<
<table></table>

You can use the "Tab trigger" snippets from the HTML bundle (installed by default). For example, if you want a body tag, you can type:
body[TAB]
and TextMate will insert the full opening and closing tag.
For more on the various HTML bundle capabilities (because there are several) see http://manual.macromates.com/en/bundles#html

Related

Keyboard Shortcut Ctrl+B and Ctrl+I in RMarkdown and RStudio

When writing reports in RMarkdown I realized that hitting Ctrl+B for bold or Ctrl+I for italic won't emphasize the text marked. Many other Markdown editors (for example the editor on StackOverflow) do this job.
For the moment I work with Shift+* after marking the text I want to show in bold which returns *text* which would be displayed in italic. However for making something bold I need to do this twice. And returning the action (removing the **) is not possible with this procedure.
Is there a hidden button somewhere in RStudio where I can turn this option on? Or is there some other solution to this problem like a package who does the job?
One way to do it is installing the addin remedy remotes::install_github("ThinkR-open/remedy") and then to map your preferred key combination to the bold formatting offered by the addon.
So, it's a two-step process. First, install remedy, and then modify the keyboard shortcuts (Tools > Modify Keyboard Shortcuts...).
After installing remedy, there should be a 'bold' option for you in the shortcuts' list to make the binding.

I18n preview shortcut for Rubymine

When I open a file on Rubymine, that has i18n string using "Ruby translate method", it displays a "preview" of the translated text instead of the actual code "t('translate_key')". When I click the text it shows up the code as expected, but I would like to know how can I make it displays the preview again for that piece of code.
I've tried many things from closing the file and opening it again but got unsuccessful. I believe that may have a keyboard shortcut to switch from "string preview" to "actual code", but haven't been able to find it.
I figured out that the correct way to do this is by folding the line (it may not seen obvious as folding is usually used to fold blocks).
The menu item is: "Code > Folding > Collapse". On Mac OS X using "Mac OS X 10.5+" keymap, the shortcut is ⌘+-
Go to the Preferences menu, IDE Settings, Editor, Code Folding and then uncheck 'Ruby i18n strings'. You will need to close and reopen the file to see the unfolded i18n strings.
place your cursor on translation code and press (ctrl-) from keyboard it displays the preview again for that piece of code.

Auto auto-complete in TextMate

I've recently switched to TextMate from Coda after getting annoyed by the long delays and general slowness of the app. There are a few annoyances in TM but it's mainly because I'm used to one over the other. One aspect that is driving me nuts however is the lack of automatic auto-complete.
For example, in a CSS document in Coda I could begin typing fo and Coda would pop up a list of font-style, font-weight etc. Selecting one of these would then show available properties, bold, light etc, again selectable. In TextMate I've begun using the Bundle auto-completition shortcuts but they're pretty useless as you have to type practically the whole thing for shorter snippets.
Is there any way of making TextMate replicate Coda's behaviour of automatically suggesting as you type? If not, are there any other editors that do (BBEdit?)? Thanks.
Pressing escape autocompletes for you. At least nowadays.
Maybe it's not as seamless as one would like, but it works.
TextMate has a simple yet effective completion function on ⎋ (escape).
It will complete the current word based on matches in the current
document. If there are multiple matches, you can cycle through these
by pressing ⎋ continuously. It is also possible to cycle backwards
using ⇧⎋.
Source
Install the TextMate bundle "GetBundles" first
I believe these two terminal commands will do it:
cd ~/Library/Application\ Support/TextMate/Bundles
svn co http://svn.textmate.org/trunk/Review/Bundles/GetBundles.tmbundle/
Then, in TextMate, press Ctrl+Cmd+T (this should be a very familiar shortcut) to bring up the window of bundles that are valid in your current scope. Type 'get bundles' or 'getbundles' and press enter when you are on the right bundle. This opens a window to search a bunch of repos for bundles. In the upper right is a search box. Enter 'CSS'. There are 5-6 CSS bundles available, I would try them out and see if one fits your needs.
TextMate doesn't have that kind of that kind of code parsing built in to the core but I know of at least one bundle (the PHP bundle, now included with TM) that does it.
You might try Espresso (http://macrabbit.com/espresso/): its auto-complete is similar.
Textmate also has tab triggers, which can be very useful and are as close as it gets to auto-complete on TextMate.
For example, if you type in "head" and then press tab, this will show up automagically:
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Page Title</title>
Textmate already has this built in for a few HTML tags, but only a very small number. So, you'll probably want to get a bundle that will expand tab triggers to cover all kinds of tags.
If you do everything that Brandon and matkins have already told you to do and search for the "HTML+" bundle (which can also be found on GitHub), this will allow tab triggers for almost all possible HTML elements and attributes.
Then, for example, you can type "p" and then the tab button and this will show up automagically:
<p></p>
with the curser in between the two tags.
You may be able to find similar bundles for CSS and other things – I haven't looked yet.
Again, this is as close to tag autocompleting that Textmate can get, as far as I have found.

Is it possible to launch an external image editor from Textmate?

Is it possible to launch an external image editor from the TextMate project drawer? I suppose the same concept would apply to launching any external editor from TextMate. Right now, if I right-click on the image file, I only have an option to open in Preview or Finder.
Thanks!
Yes. There is an (official) TM Bundle that does what you want--it's called "ImageBrowser." I installed recently and i have used it only once. It seems to work fine for the purpose you mentioned in your Question; in particular, it finds images in your current project and displays them in an image browser that runs inside TextMate.
You can get it from the Macromates SVN Repository.
TextMate respects the Finder's (well, LauchService's) "Open with" choice for each file. Whichever program would open when you double-click the file in Finder will appear in TextMate's contextual menu. Simply change this through the Finder's Get Info window for the file in question to the editor of your choice, and TextMate will respect it. It's dynamically populated, so you don't need to restart TextMate.
As far as I know, there's no method to specify a secondary program beyond the default.
I think no is the answer, but like Matt said, explore the usage of the Services menu.

Copy-paste code from Visual Studio, but paste UNFORMATTED code

Is there any way to force Visual Studio to copy selected code to the clipboard as unformatted text?
When I am copy-pasting code into Word or more often Outlook I have to do it via Notepad to get rid of the formatting...there has to be an easier way!
This feature can be turned off by editor.copyWithSyntaxHighlighting.
Visual Studio does put unformatted text on the clipboard, but it also puts formatted text. (The clipboard supports multiple simultaneous formats, and the OS assumes that they're simply different representations of the same data, although there's no technical enforcement of that point.)
The application you're using to paste then chooses its preferred format. In Word, and maybe Outlook as well, there is a "Paste Special" command that allows you to choose which format you want to use.
My department uses PureText. Sits in the system tray; copy text, click-it - strips all formatting leaving the plain-vanilla text. I'm sure it's much like PlainTextClipboard.
"PureText is basically equivalent to
opening Notepad, doing a PASTE,
followed by a SELECT-ALL, and then a
COPY. The benefit of PureText is
performing all these actions with a
single Hot-Key and having the result
pasted into the current window
automatically."
The goad for this was flaky Lotus Notes; likes to crash when pasting HTML-marked-up-text that I innocently copied from a web-page....
If you press CTRL+Z after pasting, it will reverse to the non-formatting one, because the formatting actually counts as one step after the regular paste.
When I do it choosing the little pop-up menu option attached to the wee clipboard item "Match Destination Formatting" does the trick for me.
From this blog post I got these instructions for getting rid of the black background when copying & pasting out of VS with the 'Dark Theme' activated, but the html in it can be tweaked to alter the rest of the formatting as required (e.g. set all text to black).
If required, install Productivity Power Tools
Open Tools → Extensions and Updates
Select Online (Visual Studio Gallery) and search for Productivity Power Tools 2012/2013
Download and restart Visual Studio when prompted
Productivity Power Tools Settings
Open Tools → Options → Expand Productivity Power Tools
select HTML Copy
Change the BeforeCodeSnippet option to:
<style type="text/css">.identifier {color:black !important;}</style>
<pre style="{font-family}{font-size}{font-weight}{font-style}">
Change EmitSpanClass to: True
Check EmitSpanStyle is: True
You might find http://www.extrabit.com/plaintextclipboard/ to be a useful tool. Some applications have a paste option which strips formatting, but what you really need is a copy operation that strips formatting, which VS does not offer.
In Outlook 2007, I've changed my default paste to do text only.
Go to Editor Options | Advanced
Under the "Cut, copy, paste" heading choose Pasting from other programs: [Keep Text Only]
And if you still want to paste formatted (less often in my case), use paste special...
Search editor.copyWithSyntaxHighlighting in Settings and disable it. Whoever enabled it by default must be flogged.
This Microsoft Office site offers a workaround that involves writing a macro to replace ctrl+v functionality to paste plain text all the time, but that may not be what you want. You can alternatively remap an unused shortcut (ctrl+?) to provide you with this functionality so you don't have to keep enabling / disabling the macro.
For applications that do not have a "paste special" you could use an application like PureText
The Visual Studio Extension Copy for review may be handy for you. Actually, it does not do unformatted copying, but applies it's own simple text-based template.
It supports a "Stack Overflow" format, which just removes the leading whitespace, while keeping the indentation as much as possible, and introduces some sort of header.
Get it from the from the Visual Studio Gallery and try it out.
Disclosure: I am the author of that Extension. Please notfiy me, if I can improve it to your needs.
A trick when applies:
You don't want to install an extension
Your destination application doesn't have options such as "Paste Special"..
You can copy the code and paste it in VS Code search box (shows when you press Ctrl+F). Then copy it again from there.
Then you can paste unformatted text anywhere you want.

Resources