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

English support forum

Moderators: Stefan2, white, sheep, Hacker

Post Reply
Joeyy
Junior Member
Junior Member
Posts: 44
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 » 2019-03-25, 13:55 UTC

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: 3394
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 » 2019-03-25, 14:06 UTC

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 10 Home x64 May 2019 Update, Version 1903 (OS Build 18362.329)
Intel(R) Core(TM) i7-4770 CPU @ 3.40GH, 16GB RAM
TC 9.22a x64 and x86, Everything 1.4.1.949 (x64)

User avatar
Dalai
Power Member
Power Member
Posts: 6675
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 » 2019-03-25, 15:05 UTC

Horst.Epp wrote:
2019-03-25, 14:06 UTC
Notepad 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
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
Stefan2
Power Member
Power Member
Posts: 2584
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 » 2019-03-25, 15:15 UTC

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
Show

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
viewtopic.php?p=136366#p136366

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



HTH?
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

User avatar
Horst.Epp
Power Member
Power Member
Posts: 3394
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 » 2019-03-25, 15:32 UTC

Dalai wrote:
2019-03-25, 15:05 UTC
Horst.Epp wrote:
2019-03-25, 14:06 UTC
Notepad 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 10 Home x64 May 2019 Update, Version 1903 (OS Build 18362.329)
Intel(R) Core(TM) i7-4770 CPU @ 3.40GH, 16GB RAM
TC 9.22a x64 and x86, Everything 1.4.1.949 (x64)

Joeyy
Junior Member
Junior Member
Posts: 44
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 » 2019-03-26, 02:27 UTC

@Dalai@Stefan2@Horst.Epp
Thanks!

Post Reply