Prevent Ctrl+Z deleting last line in SSMS after Script As->Alter View - tsql

I'm hoping there's just some way to disable this in SQL Server Management Studio (v17.9.1). When I Script As->Alter a view or stored procedure to a new query window, I can hit Ctrl+Z and it deletes the last line of text! I realize as I'm trying to explain this exactly what's happening: Sql is opening a new window and "pasting" the query line by line. Therefore when you undo you're removing the last line and so on.
This becomes a problem when you say, alter a view, make changes and execute, then decide to undo them all so you just hold Ctrl+Z then realize you've erased half your script instead of just going back to the starting point.
Does anyone know how to disable this or an elegant way of preventing it from happening?

This started out as a comment, but it's getting too long, so...
I don't think you can disable ctrl+z, but just like Newton's third law of motion - for every undo there's an equal and opposite redo - so if you've held ctrl+z pressed for too long, you can always restore the lines that ctrl+z deleted simply by using ctrl+y.
Other options are suggested by GSerg in his comments - you can always keep a copy of the original code in a different query window, or even a simple text editor.
One more option is to first save the content of the new query to a file, so you can always reload it's original state if you've messed things up too much.

Related

Programatically remove entry from Atom's undo stack

I've written a small piece of coffeescript code for Atom editor to update a timestamp comment on certain files just before they are saved, and it works perfectly.
Unfortunately, this modification ends up, obviously, on Atom's undo stack, so if after saving these files I undo my changes, the timestamp is undone before the previous changes. For this reason I want to remove this timestamp update from the undo stack.
I know I can pack multiple changes into a single undo transaction using TextBuffer.transact() or TextEditor.transact(), but I can't find how to just remove last entry (or entries) from the undo stack.
Is the only solution to access directly the historyProvider and mess with the undostack Array? Frankly, right now I don't know which side-effects this can have, but I don't find anything in Atom API todo what I need.
Thanks a lot in advance, as always :)
Sorry for the auto-answer, but I found a way of achieving what I want.
Using Editor.insertText(text, {undo: 'skip'}, a text insertion can be removed from the undo stack, and the same option can be provided for setTextInRange, which is what I was using previously.

Why does Emacs sometimes overwrite characters when I insert or delete?

This happens for me all the time. Upon insertion/deletion, the positions of other characters in the buffer are not shifted.
For example, with buffer contents this is important content, inserting very before important results in the two words very and important appearing overlapped, like this: this is veryrtant content instead of this is very important content
How can I fix this?
Killing the buffer and reopening of course works.
It sounds like you have accidentally turned on overwrite-mode.
That command is a toggle. It is bound by default to the keys <insertchar> and <insert>. Typically one of those keys in a keyboard key labeled Insert.
But perhaps your keyboard is sending that key when you do something else.
Does the overwriting ever turn off? If so, that would suggest that you accidentally hit the toggle key a second time.
If not, then perhaps your keyboard or terminal is itself somehow locked in an overwriting mode. Do you see the same behavior outside of Emacs?

Can't Close and Delete Open MSWord 2010 Document (ActiveDocument.Close prevents Kill command from running.)

I'm trying to close the open word document and delete it as part of my DocumentBeforeClose event. I keep running across the following code in my searches (+/- some error trapping statements):
Dim Killfile As String
Killfile = Dir$(ActiveDocument.FullName)
If Len(Dir$(Killfile)) > 0 Then
SetAttr Killfile, vbNormal
ActiveDocument.Close False
Kill Killfile
End if
I've found similar code (well, frankly almost identical code) in several places, and everyone seems to confirm that it works, but I cannot get it to run correctly in my own attempts, regardless of what module I have the code in. When run, the document always closes, but the code also stops there and never gets to the Kill command. In theory the instance of Word is supposed to keep running the script once the document closes; in my case the instance is open, but there's nothing running anymore at that point. Am I doing something obviously wrong here?
If it's helpful, in another version of the code I'm working with I have a Do While loop going through a directory and deleting documents containing "temp.doc" in the name. That code has no trouble running through and deleting closed files, but also will not delete the active/open document after closing.
Is this something I need to place in the Normal module in order for it to work? (Would reeeaally like to avoid that if possible). Thanks for any help!
Editing to add the top few relevant Search Results from Googling "MSWord VBA Delete Open Document":
http://word.tips.net/T001346_Deleting_the_Open_Document_File.html
http://geekgirls.com/2010/02/deleting-an-open-document-in-microsoft-word/
Delete doc when macro finishes
Again, the unifying factor appears to be:
Activedocument.close
Kill WhateverOpenFile
...which just plain doesn't seem to make sense.

Disable auto-scrolling in command window

A lot of the code that I write in Matlab has a very verbose output. As the program runs, information is printed to the command window, and with each new line, the window automatically scrolls to the bottom. This becomes a problem when I want to read some of the output more closely or scroll up to look at older output. I can scroll up, but only until a new line is printed, which is often less than a second.
Does anyone know if it is possible to turn off this automatic scrolling in the Matlab window? I work in a number of different Matlab versions, depending on the machine, and this happens with all of them. The answer to this might be "No", but I swear I remember having this functionality at one point.
Use the more function: http://www.mathworks.com/help/matlab/ref/more.html
more on
Then run your program. Press spacebar when you wish to see more of the output.
more off will turn it off.
You may find this workaround useful.
First launch matlab using the command line matlab -logfile 'myLog.txt' (the doc says it "starts MATLAB and makes a copy of any output to the Command Window in filename. This includes all crash reports.")
Then open your .txt file using a text editor supporting automatic refresh of content (see picture). On OSX I use TextWrangler (freely available at www) but others have been reported to have this feature (see here or here).
Results: output displays (fprintf, disp, but not the commands per se) are printed both on the Matlab console and the text editor (file is refreshed with a little lag time, below half a second I would say with my configuration). And there is no automatic scrolling. Such procedure does not seem to impact the overall performance of the script (although it may deserve some testing).

editing Rnw in Emacs, gets confused if in math mode or not

When editing .Rnw files with emacs, sometimes it gets confused as to if I am in math mode or not. Then, the syntax highlighting gets messed up, and C-f-i inserts \textit{} and \mathit{} opposite to how it normally should. Is seems like there is some bool storing the state of math mode or not, and it gets inadvertently flipped. Is there a way I can manually flip it back?
I've noticed that this usually corrects itself if I insert a new R chunk and then delete it. Not an elegant solution, but it works for me.