How to open txt file with Gvim on default when "Shift+F4" creats new txt file?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
Joeyy
Junior Member
Junior Member
Posts: 60
Joined: 2016-09-20, 10:09 UTC

How to open txt file with Gvim on default when "Shift+F4" creats new txt file?

Post by *Joeyy »

Every time I create a new txt file with "Shift+F4" hotkey, TC open it with notepad on default, but I want to open it with Gvim, how to do it?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: How to open txt file with Gvim on default when "Shift+F4" creats new txt file?

Post by *Horst.Epp »

Notepad is hardcoded in TC.
I use NotepadReplacer to make my favorite editor (SynWrite / Syn2) the system default for any calls to notepad.
https://www.binaryfortress.com/NotepadReplacer/
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
Dalai
Power Member
Power Member
Posts: 9366
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: How to open txt file with Gvim on default when "Shift+F4" creats new txt file?

Post by *Dalai »

Horst.Epp wrote: 2019-03-25, 14:06 UTCNotepad is hardcoded in TC.
Huh? No, it isn't. I've been using ConTEXT editor with Shift+F4 for over a decade now. The only place where TC uses a hardcoded editor is Settings > Change Settings File Directly which has been a discussion for many years.

@Joeyy:
See Options > Edit/View > Editor for F4, and set the editor you wish. The same editor will be used for Shift+F4 hotkey.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: How to open txt file with Gvim on default when "Shift+F4" creats new txt file?

Post by *Stefan2 »

Hi Joeyy

there are several approach.

A:
change your default Editor in TC:
Menu Configuration > Options... > Edit/View > Editor for F4
Editor: TOOLs\NotePad2\notepad2.exe "%1"
((("TOOLs" is a sub folder in my TC folder)))


B:
create a user defined command

1.) Create a user defined command in usercmd.ini
[em_F4_VBS] ;NewFile like Shift+F4
cmd="TOOLs\CMDs\CreateNewTextFile.vbs"
Param="%O.%E"


'2.) Assign a keyboard shortcut in wincmd.ini
[Shortcuts]
CS+F4=em_F4_VBS ;Ctrl+Shift+F4


'3.) Write a script, like this "CreateNewTextFile.vbs"

Code: Select all

'On Error Resume Next
'If WScript.Arguments.Count = 0 Then WScript.Quit

strPara = "New Text file.txt"
SET ARGs = WScript.Arguments
IF args.count > 0 Then strPara = args(0)

strTimestamp = year(now) &"-"& right( "0" & month(now), 2) &"-"&  right( "0" & day(now), 2)
strNewFileName = strTimestamp & "_" & strPara


NewFileName = InputBox("Enter file name to create new:","Total Commander",strNewFileName)

If NewFileName="" Then 
	WScript.Quit
Else
	'//TRICK: use "?" sign in new file name to open the text file after creation:
	IF (InStr(NewFileName,"?")) Then
		bOpenTextFileAfterwards = TRUE
		NewFileName = Replace(NewFileName,"?","")
	End If
	CreateObject("Scripting.FileSystemObject").CreateTextFile(NewFileName)	
End If

IF (bOpenTextFileAfterwards) Then
	SET WSO = WScript.CreateObject("WScript.Shell")
	TCPath = WSO.ExpandEnvironmentStrings("%Commander_Path%")
	'//WSO.Run strCommand [,intWindowStyle 0=Hide 1=Activate 2=minimize 3=maximize ...] [,bWaitTillFinish? True/defaultFalse]
	WSO.run TCPath & "\TOOLs\NotePad2\notepad2.exe " & NewFileName
	SET WSO = Nothing
End IF '(bOpenTextFileAfterwards)

C:
Use external tools, like "putfile" from our member m^2
https://www.ghisler.ch/board/viewtopic.php?p=136366#p136366

Also there are some other tools for the "F4"-button to handle different extensions:
viewtopic.php?p=293272#p293272



HTH?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: How to open txt file with Gvim on default when "Shift+F4" creats new txt file?

Post by *Horst.Epp »

Dalai wrote: 2019-03-25, 15:05 UTC
Horst.Epp wrote: 2019-03-25, 14:06 UTCNotepad is hardcoded in TC.
Huh? No, it isn't. I've been using ConTEXT editor with Shift+F4 for over a decade now. The only place where TC uses a hardcoded editor is Settings > Change Settings File Directly which has been a discussion for many years.

@Joeyy:
See Options > Edit/View > Editor for F4, and set the editor you wish. The same editor will be used for Shift+F4 hotkey.

Regards
Dalai
Ops, sorry, I confused it with the Change setting issue.
But in my case NodepadReplacer fixed that also.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
Joeyy
Junior Member
Junior Member
Posts: 60
Joined: 2016-09-20, 10:09 UTC

Re: How to open txt file with Gvim on default when "Shift+F4" creats new txt file?

Post by *Joeyy »

@Dalai@Stefan2@Horst.Epp
Thanks!
Post Reply