Sublime Text snippets in Ace Editor - sublimetext

Hey i know that we can use Sublime Texts .tmLanguage syntax in Ace Editor with the tools that comes with ace. Is it possible to even use Sublime Texts .sublime-snippet snippets in Ace Editor.

In sublime's folder You can find snippets at Packages/HTML/HTML.sublime-completions.
And then there is ace/lib/ace/snippets
folder in Ace Editor.
I haven't done it myself, but I am pretty sure that you can combine files in those folders. Have an experiment. :)
Good luck!

there is no automatic converter, but adding one is relatively straightforward,
parse xml of sublime snippet file and either keep it as json or as ace/snipmate snippets file
var sublimeSnippet = plist.parse(xml)
var aceSnippet = ""
+ "snippet " + sublimeSnippet.tabTrigger
+ "description " + sublimeSnippet.description
+ "scope " + sublimeSnippet.scope.replace(/source\./g, "")
+ "\t" + sublimeSnippet.content.replace(/\r?\n/g, "\n\t")
+ "\n"

Related

Visual Studio Community: Delete lines prefixed by a line feed

In this code
I'd like to delete the line 2207 and 2208.
I tried several replace actions in the "Search & Replace" tools but none works
\r\n WriteDumbowLog("MethodName:" & methodName)"
"\n\r WriteDumbowLog("MethodName:" & methodName)"
".$ WriteDumbowLog("MethodName:" & methodName)"
"\n WriteDumbowLog("MethodName:" & methodName)"
The correct regular expression is:
((\r\n)|\n|\r) WriteDumbowLog\("MethodName\:" & methodName\)
I used this extension https://marketplace.visualstudio.com/items?itemName=PeterMacej.MultilineSearchandReplace which doesn't work (oddly) but provide you the correct regex to replace.

How to copy/cut a file (not the contents) to the clipboard in Windows on the command line?

Is there a way to copy (or cut) a file to the Windows clipboard from the command line?
In particular with a batch script. I know how to copy the contents to the clipboard (type file | clip), but this is not the case. I want to have the whole file as I would press Ctrl + C in Windows Explorer.
OK, it seems the easiest way was to create a small C# tool that takes arguments and stores them in the clipboard:
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace File2Clip
{
public class App
{
[STAThread]
static void Main(string[] args)
{
List<string> list = new List<string>();
string line;
while(!string.IsNullOrEmpty(line = Console.ReadLine())) list.Add(line);
foreach (string s in args) list.Add(s);
StringCollection paths = new StringCollection();
foreach (string s in list) {
Console.Write(s);
paths.Add(
System.IO.Path.IsPathRooted(s) ?
s :
System.IO.Directory.GetCurrentDirectory() +
#"\" + s);
}
Clipboard.SetFileDropList(paths);
}
}
}
2017 edit: Here's a github repo with both source and binary.
This would place the contents of the file into the clipboard (accomplished by clip.exe).
type \path\to\file|clip
To get the actual file, you'll probably have to resort to some other programming language, like VBScript or PowerShell to access Windows API's. I'm not entirely certain what Explorer puts into the clipboard when you CTRL+C a file. I suspect it uses the notification system to do something more intelligent than put the path to the file there. Depending on the context of the CTRL+V, you'll get something (Explorer, Word) or nothing (Notepad).
I've forever wanted this to use in Emacs, so, inspired by this question, an answer here, and a goodly amount of NIH syndrome, I've written a C version available at
https://github.com/roryyorke/picellif
picellif also handles wildcards (it's not clear to me if rostok's C# version does or not).
copy and move are (some of) the batch commands that copy/paste and cut/paste files, respectively. We don't use the terms paste or cut when dealing with files but if I understand you there is a need to copy a file to another location and to move files to another location.
You can try Swiss File Knife (SFK):
sfk toclip
Copy stdin to clipboard as plain text.
type test.txt | sfk toclip
Copies the content of ASCII file test.txt into the clipboard.
sfk list | sfk toclip
Copies a file listing of the current dir into the clipboard.
sfk fromclip [-wait] [-clear]
Dump plain text content from the clipboard to the terminal.
-wait : block until plain text is available.
-clear: empty the clipboard after reading it.
Example: turn backslashes into forward slashes. Imagine you have the following text open within Notepad:
foo/bar/systems/alpha1.cpp
foo/bar/systems/alpha2.cpp
foo/bar/systems/beta1.cpp
And for some reason you need the first line in a format like this:
foo\bar\systems\alpha1.cpp
Then you may do it this way:
Mark the first line using SHIFT + CURSOR keys.
Press Ctrl + C or Ctrl + Insert to copy it into clipboard
On the Windows command line, run this command (for example, from a batch file):
sfk fromclip +filter -rep x/x\x +toclip
Back in the editor, press Ctrl + V or Shift + Insert, pasting the result from the clipboard.
As you see, the line changed into "foo\bar\systems\alpha1.cpp".
You can use Command Line Copy and Paste Files utilities on Sid's Bytestream.

Running console commands to convert with ImageMagick from within Unity 3d

Folks!
So, I'm attempting to convert a PDF to a .png, as the title implies. I'm using the software package ImageMagick. I want to use this package to convert pdfs to pngs on-the-fly from a Unity 3d project -- so that the application can display the PDFs as .png textures in-game when it needs, but still preserves them as PDFs for smaller file sizes. I'm not quite sure what I've done wrong, here -- but when I run it in Unity, all I get is an open cmd prompt without my command in it. Is there something obvious that I'm missing, here? Here's the code:
using UnityEngine;
using System.Collections;
using System.IO;
using System.Reflection;
using System.Security.Policy;
public class CommandLineTest : MonoBehaviour {
// Use this for initialization
void Start () {
string convertedDirName = "ConvertedPDFs";
string currDir = System.Environment.CurrentDirectory;
System.IO.Directory.CreateDirectory(currDir + #"\" + convertedDirName);
string strCmdText;
strCmdText= #"/c " + currDir + #"\ImageMagick\convert.exe " + currDir + #"\PDFs\Appointment.pdf " + currDir + #"\" + convertedDirName + #"\" + "Appointment.png";
System.Diagnostics.Process.Start("CMD.exe",strCmdText);
//ImageMagick
print(strCmdText);
}
}
When the print statement at the end runs, it prints the following string: c/ convert /c F:\Documents and Settings\Administrator\Desktop\ImageMagickTest\ImageMagick\convert.exe F:\Documents and Settings\Administrator\Desktop\ImageMagickTest\PDFs\Appointment.pdf F:\Documents and Settings\Administrator\Desktop\ImageMagickTest\ConvertedPDFs\Appointment.png
Does anything appear obviously wrong, to you? I should mention that ImageMagick's convert application is not actually "installed" on my system -- I'm just using the "portable" version and have thrown it in my project folder. So I was hoping that the "convert" command line would still work. Does this mean that I can't access it with a dos prompt? If I can't, then how do I pass an image to the "convert" program in imagemagick using, provided I know that it's going to be in my project's folder?
EDIT: Some people have suggested that I access convert.exe instead of cmd.exe, and to attempt to just feed the image paths to it that way. So here is the second way I'm trying it:
strCmdText= currDir + #"\PDFs\Appointment.pdf" + " " + currDir + #"\" + convertedDirName + #"\" + "Appointment.png";
System.Diagnostics.Process.Start(currDir + #"\ImageMagick\convert.exe",strCmdText);
Try using some other commands (like dir) to figure out where you are in the filesystem and what is going wrong.
Also remember that if you are using the portable version and it is not in your path, you will have to execute it from the same directory as it is in.

ctags for autocompleting c++ library functions in vim

After following some tutorials i tried to use exuberant ctags to autocomplete e.g. openGL functions. I used the command
ctags -R --languages=C,C++ --c++-kinds=+p --fields=+iaS --extra=+q ./
in the directory where the freeglut.h, glew.h etc resides. Then copying this to a directory pointed by in the .vimrc file (with 'set tags+=./myTag/tags' in my .vimrc)
When I try to autocomplete some glut functions i dont get the funciton parameters listed, only the function itself gets completed, but without the parameters.
On the other hand, when Im applying the ctags command above to a .cpp file in the same directory where my main file resides it autocompletes with the function parameters.
Im probably missing some essential information here.
Firstly, I'm tired of managing ctags by hand, and I wrote plugin Indexer for that. It provides painless automatic tags generation and keeps tags up-to-date. For detailed information, see the article: Vim: convenient code navigation for your projects, which explains the usage of Indexer + Vimprj thoroughly.
And secondly, for code autocompletion, I suggest you to use clang_complete. It provides real, perfect C/C++/Objective-C completion from true compiler, not ugly method by tags.
In your .vimrc file, before adding the tag files, add the directory. So if you added the tage in $HOME/.vim/tags directory you need to add the following line
set tags=~/.vim/tags
The section (in your .vimrc) referred to OmniCppComplete may be something like this:
" configure tags - add additional tags here or comment out not-used ones
" Setting the directory...
set tags=~/.vim/tags
" Adding the tag files
set tags+=~/.vim/tags/cpp
set tags+=~/.vim/tags/gl
set tags+=~/.vim/tags/sdl
set tags+=~/.vim/tags/qt4
" set tags+=$HOME/.vim/tags/standard
" build tags of your own project with Ctrl-F12
map <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview

Sublime Text 2 - Default Document Type

Is there a way to set a default document type when saving a NEW FILE?
I created several new files and I want to have a default value of .txt when saving a NEW FILE.
Create a new plugin Tools > Developer > New Plugin...
Paste this in:
import sublime, sublime_plugin
class EverythingIsPowerShell(sublime_plugin.EventListener):
def on_new(self, view):
view.set_syntax_file('Packages/PowerShell/Support/PowershellSyntax.tmLanguage')
Save and call it NewTabSyntax.py. New tabs will now default to Powershell.
You can change the syntax to whatever you prefer. To find out the "path" of a particular syntax, simply open a file of that syntax, open the console (View > Show Console) and type:
view.settings().get('syntax')
This plugin does it:
https://github.com/spadgos/sublime-DefaultFileType
seems pretty great.
Edit:
Ok, two things, there currently seems to be a small bug so the text file syntax is not being correctly picked up due to the whitespace in the filename. In addition you need to set the "use_current_file_syntax" to false, (otherwise the new file will default to whatever filetype you have open already when you hit Ctrl-N)... So the fix/workaround is this:
Put the following code in: Packages/User/default_file_type.sublime-settings
{ "default_new_file_syntax": "Packages/Text/Plain_text.tmLanguage",
"use_current_file_syntax": false }
NOTE THE UNDERSCORE.
Next, find the "Plain text.tmLanguage" file and copy and rename it (in the same folder) as "Plain_text.tmLanguage". [be sure to copy/duplicate it, do not just rename it, as it may have dependancies]
Restart, just to be sure, and this should do the trick.
Also note this plugin only works for new files created with Ctrl-N.
Working after these steps:
1.Uninstalled
2.Installed using Package Control
3.Test using default install (type Jave) <-- worked
4.Copy and Renamed file Sublime Text 2\Packages\Text\Plain text.tmLanguage > Sublime Text 2\Packages\Text\Plain_text.tmLanguage
5.Changed file Sublime Text 2\Packages\Default File Type\default_file_type.sublime-settings >
`{ "default_new_file_syntax": "Packages/Text/Plain_text.tmLanguage", "use_current_file_syntax": true }`
-- All working.
I did not need to copy any files into the 'Packages/User' folder
#fraxel _ Thanks for all the help and quick response.

Resources