问题描述
我想将键盘键绑定设置为 Windows默认设置,我想在启动时使用startup.m
进行此操作,因为我希望在大量系统上设置此设置.
I want to setup the keyboard keybindings as Windows Default Set and I would like to do this at startup using the startup.m
because I want this setting to be set on a large number of systems.
首选项对话框中的等效设置为:MATLAB > Keyboard > Shortcuts > Active Settings: Windows Default Set.
The equivalent setting in the preferences dialog is: MATLAB > Keyboard > Shortcuts > Active Settings: Windows Default Set.
请参阅第8行
% TODO set startup script in $HOME/Documents/bin/matlab/startup.m in Terminal
% all commands here will be run at startup etc startup.m
% TODO set user path as relative by $HOME/Documents/bin/matlab/
%userpath('/home/masi/Documents/bin/matlab/')
% TODO How to set up userpath outside this Matlab script in Terminal?
% http://stackoverflow.com/a/38188945/54964
if ( not( com.mathworks.services.Prefs.getStringPref('CurrentKeyBindingSet') == 'Windows' ) )
com.mathworks.services.Prefs.setStringPref('CurrentKeyBindingSet', 'WindowsDefaultSet.xml')
end
% Event errors else with touchpad scroll
!synclient HorizTwoFingerScroll=0
Matlab:2016a
系统:Linux Ubuntu 16.04
Matlab: 2016a
System: Linux Ubuntu 16.04
推荐答案
如果要以编程方式执行此操作,则可以使用未公开的功能来设置首选项.
If you want to do this programmatically you can do it using the undocumented functions for setting the preferences.
com.mathworks.services.Prefs.setStringPref('CurrentKeyBindingSet', 'Windows')
如果要使用其他键绑定,可以从首选项"对话框中显式设置值,然后调用以下命令来检索该值.
If you want a different keybinding, you can set the value explicitly from the preferences dialog and then call the following to retrieve the value.
com.mathworks.services.Prefs.getStringPref('CurrentKeyBindingSet')
该命令每次MATLAB安装仅需运行一次,因此将其放置在startup.m
文件中可能会过大,并且还会阻止用户更改您的默认设置.
This command should only have to be run once per MATLAB installation so placing it within the startup.m
file may be overkill and would also prevent users from being able to change your default settings.
这篇关于如何以编程方式指定MATLAB编辑器按键绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!