Notepad++/Eclipse sql code auto-indent option? - sql

DDL gets especially ugly. Is there any option of SQL auto-indenting for Notepad++? I've tried to do it in Eclipse, but the code doesn't react to auto-indent.

Yes, there is a free/open-source T-SQL formatting plugin for Notepad++, called "Poor Man's T-SQL Formatter". It is available in the NPP "Plugin Manager" plugin list (gets updated every once in a while automatically), and is also available for manually downloading/installing from here: http://www.architectshack.com/PoorMansTSqlFormatter.ashx
If you just want to check it out without adding to notepad++, you can check the online formatting site:
http://poorsql.com
(disclaimer: I wrote these tools :))

There is also another free SQL Formatter plugin for Notepad++ with code folding and coloring and 100+ formatting option here: SQLinForm Free Notepad++ Plug-n. A free version is also available.

Related

Can I use UTILS in Oracle?

I want to ask if I can use the following in Oracle:
UTILS.CONVERT_TO_VARCHAR2
for instance:
SELECT insertData,
UTILS.CONVERT_TO_VARCHAR2(insertData,10,p_style=>104) insert_short
FROM students
If it is not possible to use UTILS package, so which alternative I can use?
Basically, yes. My guess is that you've taken some SQL Server T-SQL and run it through the Oracle SQL Developer Translator (Tools - Migration - Scratch Editor) and this is what came out the other side. UTILS is a package which SQL Developer will generate for you if you click on the second icon from the left in the scratch editor - it's a brown package tied up with red string by the looks of it.
This generates a bunch of PL/SQL - Search in it for CONVERT_TO_VARCHAR2 (there are several overloads) and there is the code you can use however you want. You will of course also need to familiarise yourself with GET_FORMAT_FROM_STYLE.
As an aside I can't see how the scratch editor creates the package specification, so you'll need to do this by hand it would seem.

Can I do VBA programming with Vim?

Part of my job right now is to build some dynamic functionalities into Microsoft Office documents. The only means I've found to do this is through VBA - and thus, the VBA editor which comes built in to Office docs.
The VBA editor is awful. It's missing a million different functionalities that modern development environments need to support. But the worst part is that I'm a hard-core Vim lover, and the VBA editor is barely any better than notepad.
So: Is there any way I can effectively use Vim to do VBA programming? Short of copy-pasting my code into the VBA editor from a different window when I want to try it?
I've never used the VBA editor, but here's something I've done with MS Visual Studio. (MSVS's editor does have some nice features, but I still prefer vim for most editing.)
I open or create the source file in MSVS. I then get the full path to the file (by right-clicking on the tab and selecting "Copy Full Path"), and open the same file in vim in a different window.
I use alt-tab to bounce back and forth between vim and MSVS. When I make a change in vim, I use :w to write the change, then alt-tab back to MSVS. The MSVS editor notices that the file has changed on disk and offers to read the updated version.
Alternatively, if I change the file in MSVS, I write the file (File > Save ...), then alt-tab to vim and use :e! to read the updated file into the vim buffer.
There's no need to copy-paste the code, since both editors are operating on the same disk file. I just have to be very careful not to make changes in both vim and MSVS without writing the file to disk.
It's ugly, and it's not for everyone, but it works for me. Maybe it will work for you.
I use Cygwin, so it's actually a little more complicated; Cygwin programs, including vim, don't recognize Windows-style paths. I can do this:
vi $(cygpath 'WINDOWS_PATH')
where WINDOWS_PATH is pasted from the full path I get from MSVS. The single quotes are necessary to keep the shell from interpreting the \ characters. If you're using a Windows native vim, this step isn't necessary.
That's an interesting opinion. I used VI briefly about fifteen years ago and based on that I contend that the VBA editor is far more suited to its purpose than VI (or VIM?) would be. Is there one particular piece of functionality that it is missing from the VBA editor that precludes you effectively using it for its purpose (editing VBA)? VBA has not been enhanced for many many years, but the fact is it can't be killed off because everyone finds it so easy to use.
If you wish you can write some piece of code in your preferred language that manipulates your word document via COM objects (if it supports that). Then you can call your external piece of code from a simple stub within your Word document. You need to get around some security constraints though in your Word document.
For example I could write some code in VBScript or VBA or Powershell or .Net that manipulates a word doc. I can call that from a small piece of VBA (that might be attached to a button or something in the standard word toolbar)

Other options for a Rebol editor|IDE?

I currently use Programmer's Notepad with the Rebol syntax scheme. It's not bad--does any insightful person have another suggestion?
For my Windows programming work I use the Zeus editor, but I'm not sure if it does Rebol?
Another windows option is TextPad. It is commercial but it is quite a useful editor.
There are 2 Rebol syntax files available from the official site
http://www.textpad.com/add-ons/synn2t.html
I also wrote a TextPad syntax file generator uploaded it to rebol.org
http://www.rebol.org/view-script.r?script=textpad-syngen.r
It is probably quite easy to modify this script to support other editors.
vim.
Especially with the following binding in your _vimrc/.vimrc:
nnoremap <Leader>fr :w<CR>:silent ! %<CR>
In normal mode, Leaderfr saves your current file and executes it: (fr is a memo for 'fast-run')
:wEnter save current file
:silent execute without messages: ! open shell % paste current file name Enter
Leader is usually \ key, I have this mapped to spacebar. In case anyone is interested on how to do that, post a comment.
Programmer’s Notepad better than Crimson Editor with Code Folding and Great Project Management
http://www.pnotepad.org/
It's opensource so you can even modify it in C++
For Windows, there is Crimson Editor or E with the REBOL bundle.
For Mac, there is TextMate.
Emacs, I believe has a REBOL syntax too.
Sublime Text is a really nice Windows editor (commercial, but reasonably priced) that supports TextMate configurations (well, at least for syntax and snippets) so if you manage to get a REBOL bundle from somewhere, you can use it with this.
SciTE also has REBOL syntax coloring support because the Scintilla editor component it's based on includes this.
Notepad++ should also support REBOL syntax coloring, being Scintilla based, but as it is currently distributed, the support is not compiled in. If you're so inclined, you could probably compile it yourself and add the support back in. It might be worth it because Notepad++ is quite a good editor too.
I can't include proper links because I don't have enough rep, but this should do:
www.sublimetext.com
www.scintilla.org/SciTE.html
www.scintilla.org/index.html
notepad-plus-plus.org
http://rebol.wik.is/index.php?title=Notepad%2b%2b
which is a REBOL plugin for Notepad++
I use JEdit which not only has REBOL syntax highlighting but also auto-indenting. It has most of the features you'd expect from a text editor (e.g. block selection, configurable keyboard shortcuts).
There are versions for Windows, Mac OS X and Linux so if you choose to work cross-platform you won't need to learn a new editor. The web page is Jedit.org1
I use UltraEdit.
with its advanced project, syntax highlighting, macro, command-line control and total keyboard shortcut configuration, per language and project, you can program the editor to do just about all of what you need at a single click of the mouse, or keyboard.
my setup starts rebol on any file, and assigns a launch "default project script " to a shortcut, so wherever I am in the files, I still launch the project's relevant script. change project, it will run that new project's scripts. another key for unit tests, another key for "find in all opened files, etc, etc..
also, the actual text-exiting, when combined with a few macros which create functions, objects, and more using the clipboard and "currently highlighted" text makes it much faster than any Visual IDE including MSVC.
ultra edit itself has thousands of other advanced features, and they all work... really they do.
I've tried other editors and they always fall short when I start to push them.
yeah, you have to buy it... but its cheap (like one or two hours of your life salary ;-)
so considering you might use it for several months or years... its a cheap investment.
also, ultra edit is now released on linux and the mac port is just around the corner.
I use EditPlus for several years, it is not free but not expensive. It has Rebol syntax highlighting file (downloadable from its web site).
It is especially useful & very fast if you work with huge files (over 100 mb) or with lots of files (say 300 files.), find & replace takes a second.
For syntax highlighting and a simple autocomplete, you can use http://komodoide.com/komodo-edit/.
It's free and open source with several nice features, including folder browsing while editing, which I personally find very useful.
There is also a bunch of other languages supported in case you want to take a closer look and give this editor a chance.

Standard IDE/editor format for expanding snippets?

Is there any kind of standard across editor and IDEs for expanding snippets?
Specifically, I would like to write a patch for an API that would provide a code snippet database that could be imported into different editors/IDEs and expand on demand.
I am writing something for vim (my editor of choice so that)
:expand theme_some_function
would then insert
/**
* Override of theme_some_function($&arg)
**/
MYMODULE_some_function(&$arg1) {
// contents of the function go here
}
which is how you override a function in Drupal.
Originally I was writing this so that it would go find the file through ctags and copy the function and s/foo/bar/ what needs to be changed. It was suggested that I could expand this to other editors, so I was wondering if there was a standard that I might use.
But in general, is there any kind of editor standard that might give me ideas about opportunities to write something for many editors at once?
There isn't really any such editor standard, no.
I've not found any such standard. But here are a few points for exploration.
• Microsoft publishes a spec for an XML-based format of code snippets.
Code Snippets Schema Reference (Visual Studio 2012)
• Wikipedia has an article on code snippets but makes no mention of standards.
• This web page for Code Collector Pro (Mac OS X app) mentions:
Support for .snippet Files – A new common file format for all snippet managers
…but provides no information or links about such a format.

How do you print your programs to MS Word?

We have a project, and the professor asked us to print the program codes using microsoft word. however when i pasted all my codes in ms word it turns out that it doesn't have coloring, those nice programming fonts.. It just looks awfully ugly in microsoft word..
I want this to be printed on papers very gorgeously. Like what we see in our notepad++
If you are on Windows, you can open the source code in Visual Studio (assuming it is C++, C# or VB), copy the code, and paste it to Word.
"Visual Studio" to "Word" does keep the formatting (color and fonts).
I do not use Word for this when I can avoid it. It's simply not very good at keeping the formatting and doesn't provide really good-looking prints.
The line-breaking isn't program-aware.
The paragraph breaking isn't program aware.
The keeping of the formatting from VS doesn't do structure-based markup, does it?
The typesetting engine of Word is a lot worse than TeX or Quark/Indesign
Microsoft Word is very handy for code reviews. Particularly if you don't want to splurge for one of the tools explicitly designed for peer code reviews. Each reviewer can insert their comments and/or modify the code themselves right in the document. If you keep track changes on then you can see what was changed and accept or reject the changes. During the review you only have to cycle through the comments and changes. When you are all done, you can simply copy and paste the final product back into the source file. It beats having to take a list of comments, decipher them and then incorporate the requests yourself.
EDIT: We use Visual Studio. So Cut/Paste between the source and Microsoft Word works fine, except in the cases where the line length exceeds the page size.
If you have the NppExport Plugin, go to
Plugins -> NppExport -> (Then you can choose between "Export to RTF", "Copy RTF to Clipboard", or "Copy all formats to clipboard")
Then open it in Microsoft Word if you choose export to rtf, or paste it to Word if you choose copy to clipboard
Hope this helps
I tried it for my SQL assignment and it works
I'm not sure I understand the question, but if you're asking "how do I put my source code into Word and make it look pretty like Notepad++," you'll want to do some research into automating Microsoft Word.
Word automation using C#
OLE Automation using Word (Article)
Microsoft Word Automation Class
This may seem obvious, but how about you just print it from notepad++?
Eclipse does the same thing told by decasteljau.
When you copy code from eclipse, and then you paste on Outlook, the code keeps its colours.