I have a costumer showing Notepad with a large set of data that looks totally misaligned if word wrap is on and I want to force it off. Is there a command switch to do this?
I dont think there is a command switch to do this at all. If you want to force it off all the time then you may want to edit the registry:
Hive: HKEY_CURRENT_USER
Key: SOFTWARE\Microsoft\Notepad
Name: fWrap
Type: REG_DWORD
Value: 0
You could even create a .reg file and put it in a batch file to run it and reset it every time notepad runs.
Usually though if you have word wrap turned off, when you open it up again, it will still be turned off.
you could just turn it off by going to Format -> Word Wrap.
I do not believe there is any command-line option to do that.
You can however set the default behavior by setting the registry-value HKEY_CURRENT_USER\Software\Microsoft\Notepad\fWrap to 0.
Depending on your exact requirements, you might be able to solve your problem by making a bat-file that modifies the registry before starting Notepad. That would be a rather large hack, though.
You could just use Wordpad instead of Notepad, it has word wrap off by default.
Related
In this tutorial many setting are configured so Vim works well with Python. I'd like to use some of the settings only on Python files as I will also use the editor to edit lots of sql files.
Is this the correct way to create Python specific settings?
Create a file python.vim and locate it in the following directory:
M:\vimfiles\after\ftplugin\
Add the following to the file:
setlocal tw=79
setlocal colorcolumn=80
setlocal highlight Colorcolumn ctermbg=233
Do I need to use setlocal or will set suffice? Is setlocal highlight correct syntax?
You're mostly right. The use of ~/.vim/after/ftplugin/python.vim is strictly only necessary for settings from the default ftplugin/python.vim file that you want to overrule, but it's also okay to put other Python-related stuff in there. If it gets out of hand, you can split off things into e.g. ~/.vim/ftplugin/python_tools.vim or .../python/mappings.vim (see :help ftplugin-name).
setlocal
Yes, you need to use :setlocal, otherwise your settings will leak into other buffers opened from the Python buffer.
colorcolumn
The 'colorcolumn' setting is window-local, not buffer-local. Filetype plugins should change buffer settings (as the filetype is associated with a buffer, and windows can display different buffers during their lifetime). Therefore, it may happen that the colorcolumn will persist when you, say, edit a Java file in the same window. You'd need to set up elaborate autocmds to make this fully work, but depending on your workflow, you may never be affected by this, or just don't bother.
:setlocal highlight Colorcolumn ctermbg=233
Highlighting is global; you cannot simply prefix setlocal, this won't work! Just define the color with :highlight once in your ~/.vimrc or color scheme, and it'll suffice. Changing the color per filetype would again require autocmds to fully work.
I store my Python-specific settings is in $HOME/.vim/ftplugin/python.vim, since I do nothing to conflict with $VIMRUNTIME/ftplugin/python.vim. If you want to overrule what the ftplugins with your Vim distribution set up, then $HOME/.vim/after/ftplugin/python.vim is what you want, as it is read afterwards.
setlocal will set a variable for the specific buffer. This means that if you open a c file, in the same session, it won't inherit these settings. I would recommend using setlocal.
I wanted keep my users from running "dir" in the command line, so I used DOSKEY to alias "Dir" to "CLS". The testers found out that putting a space before "DIR" will circumvent the alias.
I've tried to put a space before "DIR" when setting up the DOSKEY, but the command prompt ignores the white space.
Anyone found a way of making DOSKEY acknowledge spaces?
Thanks.
Deny your users the List Directory contents permission on all relevant locations. That's probably the easier way. That way they can run dir but it won't be of any use.
I'm not even trying to figure out why you want such a thing, though.
Regarding doskey: As you noticed, macro substituion is done literally and only at the beginning of the command line. So what do you want to do? Create macros for dir to cls with 1, 2, 3, ..., 8188 spaces before it?
Blacklisting almost never works, and it certainly isn't going to in this case. You can, for example, list the files in a directory simply by pressing TAB repeatedly.
Instead, use whitelisting. Write a console application that takes user input, checks that the input is a command that the user is allowed to run, and if so, passes that command to the shell - or, better still, implement the "approved" commands yourself, so that (a) there can't be any trickery with special characters, and (b) you can remove cmd.exe from the approved applications list - you are using software restriction policy, right?
Even if you could figure out how to make your DOSKEY macro idea work (I don't think you can), it would be pointless. Your users could easily circumvent the restriction by creating the following batch file:
#dir %*
DOSKEY macros do not work within batch files, so there is nothing to stop the batch file from executing. And your users could name the batch file anything they want, so you would have a devil of a time policing.
(if not applicable to SO, please refer to another appropriate place, thanks).
When using the registry to associate file extensions and application, I put in the full filename of my application, but that does not work well, only if I use the 8.3 filename.
for example ( taken from the registry) this works:
[HKEY_CLASSES_ROOT\Toto.Document\shell\myVerb\command]
#="C:\\my\\path\\bin\\Debug\\bin\\myexe_~1.EXE /dde"
[HKEY_CLASSES_ROOT\Toto.Document\shell\myVerb\ddeexec]
#="[myVerb(\"%1\")]"
but this does not work :
[HKEY_CLASSES_ROOT\Toto.Document\shell\myVerb\command]
#="C:\\my\\path\\bin\\Debug\\bin\\myexecutable.EXE /dde"
[HKEY_CLASSES_ROOT\Toto.Document\shell\myVerb\ddeexec]
#="[myVerb(\"%1\")]"
The action is called by right-clicking on the file in Explorer, I get the error :
"Windows cannot find 'c:\users\me\desktop\tata.toto'. Make sure you typed the name correctly, and then try again".
I'm creating the keys programatically with CRegKey and using GetModuleFileName to get the application path.
2 questions :
- I'm probably missing something in my registry entry ? (i've tried quoting the paths, but does not work)
- Can I get the "short" filename ? (searching a little bit seems that GetShortPath should work, but not always!)
Thanks.
Max.
(edit 22/03/2011)
I tried using quotes but it did not work (with /dde)
I decided to use normal parameters instead of /dde and it seems to work nicely with the normal path (not shortened like stated above).
I'm still not certain why when creating a simple MFC SDI project it will write out registry values with the old short name instead of the long name.
Thanks again.
Max.
Try creating the key with another couple of double-quotes (note between .EXE and /dde:
#="C:\\my\\path\\bin\\Debug\\bin\\myexecutable.EXE" "/dde"
I'm trying to save a macro to the file I'm editing.
All goes well until I close and reopen the file. When I reopen the file, the pasted macro
<80><fc>^B Setup^M<80>
has become
■üSetup^M■
I assume this is encoding related but it's beyond me on how to resolve it.
Following are some settings that might be relevant:
fileformat=dos
fileformats=dos,unix
fileencoding=latin1
fileencodings=ucs-bom,utf-8,latin1
encoding=utf-8
Does anyone have an idea what I need to change to make it work?
Edit
I had no idea where the <80><fc>^B sequence was coming from.
It appears to be inserted into the macro when I type //***** Setup with the SHIFT key pressed up until the S from setup. The macro gets pasted as //*****<80><fc>^B Setup
Note 1: I use an Azerty keyboard. For the keys / and *, I need to press the shift key.
Note 2: A solution is to not hold the SHIFT key when typing the space character between //***** and Setup. Holding the shift key mearly has become an automatism when typing that pretty much used sequence.
you are using the gui with -W option? Then read that question. It is really related to it.
I have an application that has 'macro' capabilities. When I map some keys on the keyboard to perform the 'macro', I can also have it launch vbscript instead.
What i'd like to try and do is within my vbscript figure out what keys were used in order to launch the script. Is it posible to do this? Could there be a way in vbscript to figure out what keys were last touched on the keyboard and then I could apply my logic.
The purpose of doing this is to keep the code in a single .vb file instead of several seperate .vb script files(one for each keyboard mapping, possible 3-4). Obviously we are looking to just maintain 1 file instead of multiple files with essentially the same code in each one.
I am leaning towards the idea that this is not possible, but i figured this would be a worthy question for the masses of StackOverflow. Thanks for the help everyone!
What you are asking for is not possible.
Can you change your VBScript to accept parameters and then call it with a different parameter based on which hotkey was selected?
I agree with aphoria, the only way to make something like this possible is if your keyboard mapping software allows you to assign a script/command with parameters/arguments. For example if you used
c:\Temp\something.vbs
then you would change this to
%WINDIR%\system32\wscript.exe c:\temp\something.vbs "Ctrl-Alt-R"
Then in your vbscript code you could collect the argument using the wscript.Arguments object collection to do actions based on what argument/parameter was passed. See the following two links for more info:
http://msdn.microsoft.com/en-us/library/z2b05k8s(VS.85).aspx
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0915.mspx
The one possible approach you may use is to install keylogger and read its log in your VBScript.
For example save script start time in the very beginning of the script
StartTime = Timer()
and then read one log record of your keylogger before this time.