In Windows avoid nano triggering overwrite mode on cmd line

5

2

In Windows 8 I have installed nano, because it's my preferred command line text editor.

When I use it, it works normally, just as it would on any Linux distribution:

C:\>nano file.c 

However, when I return to the cmd prompt overwrite mode is always enabled as if I had pressed the insert key. This is highly annoying because I'm frequently going back and forth between nano and the cmd prompt.

Is there a way to fix this?

Hack-R

Posted 2015-05-11T00:17:15.600

Reputation: 369

Please report a bug to the authors of nano. – Simon Richter – 2015-05-11T06:42:44.963

Answers

4

@echo off
nano %1
echo WScript.CreateObject("WScript.Shell").SendKeys "{INSERT}" > Ins.vbs
cscript //B Ins.vbs
del Ins.vbs

Save the above as a batch file and call with the file name you want to edit.

Karan

Posted 2015-05-11T00:17:15.600

Reputation: 51 857

That seems to fix the following command-line command, but then the one after that reverts to overwrite mode again. At least that's the case for me on Windows 7. On closer look, looking in the command window "Properties" menu, "Options" tab, nano somehow clears both "QuickEdit Mode" and "Insert Mode". – Craig McQueen – 2015-11-06T06:02:17.057

I assume a call to SetConsoleMode() would solve it. I don't know how to script that with VBS though.

– Craig McQueen – 2015-12-21T22:20:56.353