Awesome
q REPL for Sublime Text 3
Connect to remote q sessions and execute q statements in Sublime Text
Cmd + alt + q
to select/add/modify your q connectionsCmd + Enter
to send current line or highlighted block of text to selected q session and show results in the output panelCmd + Shift + Enter
send the command as above, but show results in PhantomCmd + e
same as above, but show result in popupCmd + j
same as above, but get result as json (requires .j.j from kdb 3.x/4.x)- Run custom routines with
Cmd + alt + r
- 3 result modes: output panel, inline popup, and phantom (inline block)
- Syntax highlighting (from atf1206 https://github.com/atf1206/q-kdb-syntax, based on kimtang's https://github.com/kimtang/sublime-q)
- Status bar with rows, column, time, mem usage
- Syntax autocomplete
- Plot table data in html/js (similar to Studio for Kdb+ - with a few customizations)
[change Cmd to Ctrl for windows]
Shortcuts
F1
open help at cursorF2
print variable at cursorShift + F2
browse table variable at cursorF3
show type at cursorF4
plot latest data in browsershift + F4
show latest data in browser using datatable jsF5
show environmentsshift + F5
show memory usageF6
show table and column names
[hold shift to show output in inline popup instead of output panel]
Installation
via package control https://packagecontrol.io/packages/q%20KDB
Features
Charts
Shortcut F4
will plot an html/js chart from the latest REPL result (the usage is similar to Studio for Kdb+ - with a few chart customizations). See js/canvasjs/example.q
/default is line chart
lineData: ([] ts: 2019.01.01D00:00 + 1D * til 10; price: 10000 + 10?100)
/multiple series - 1 column per series
multilineData: ([] ts: 2019.01.01D00:00 + 1D * til 10; price: 10?100; price2: 10?200)
/change to column chart if first column type is symbol
colData: ([] sym: `a`b`c`d`e`f`g`h`i`j`k`l; volume: 12#100 200 300)
/you can also have multiple series for column chart
multicolData: ([] sym: `a`b`c`d`e`f`g`h`i`j`k`l; volume: 12#100 200 300; volume2: 12#400 330 210)
/use candlestick automatically if column name contains open, high, low, close. with optional volume column
ohlcvData: ([] date: 2019.01.01 + til 5; high: 105 99 150 120 180; low: 99 84 110 110 150; close: 102 99 105 120 180; open: 100 90 110 120 140; volume: 10000 15000 9000 12000 11000)
/multiple series - if second column type is symbol
multiSymData: ([] date: 6#(2019.01.01 + til 3); sym: raze 3#'`a`b; price: 100 + 6?100)
/auto generate 2nd axis if range is more than 50 times different
needAxis2Data: ([] time: "z"$2019.01.01 + til 3; a: 3?100; b: 3?1000; c: 3?100; d: 3?100000)
/can also plot list or dict directly
10?100
(`a`b`c)!(100; 120; 130)
/override option by adding chart hints
/s - change type to scatter by prefixing s: to column name
`ts`s:a`s:b xcol pointData: ([] ts: 100 * til 3; a: 3?100; b: 3?1000)
/y2 - specify 2nd axis by prefixing y2: to column name
`time`a`y2:b xcol ([] time: 2019.01.01 + til 3; a: 3?100; b: 3?1000)
/bu - bubble chart will use next column as bubble size
`time`bu:a xcol ([] time: 2019.01.01 + til 3; a: 3?100; b: 3?1000)
Output
There are 3 output modes to show results from q queries:
Cmd + Enter
output panel - I mostly use thisCmd + Shift + Enter
inline phantom - Use this when you need some reference dataCmd + e
overlay popup - I don't use this so much
Extra: shortcut Shift + F2
lets you browse the table variable at cursor (utilizing .h.jx
)
Custom Routines
Define your own custom routines. Shortcut Cmd + alt + r
will bring up custom routine options. For example:
"routines": [
{
"name": "show",
"description": "show variable at cursor",
"command": {"qstatement": ".Q.s {0}", "output": "q_out_panel"}
}
]
Where {0}
is the variable name at cursor. You can also define shortcuts by referring to the routine by name:
{ "keys": ["f2"], "command": "q_routine", "args": {"name": "show"}, "context":[{ "key": "selector", "operator": "equal", "operand": "source.q" }]},
See more example in settings/sublime-q.sublime-settings
Please feel free to open issues for any feedback, bugs, or feature requests.
Contribute
Clone this git repository into your Sublime Text 3/Packages
directory.
NOTE: You may need to change dir to q KDB
- Windows:
C:\Users\[username]\AppData\Roaming\Sublime Text 3\Packages
- OS X:
~/Library/Application Support/Sublime Text 3/Packages
git clone https://github.com/komsit37/sublime-q.git 'q KDB'
From sublime text, run package control: satisfy dependencies (you may need to open package folder in sublime text first). This will install numpy as a dependency package to your packages folder
Supported OS
- osx_x64
- windows_x64
- linux_x64
Unsupported OS
Support could be extended by adding the proper numpy 1.8 build with python 3.3 (see https://github.com/komsit37/sublime-q/issues/12). Please send a PR if you can build any of these:
- osx_x32
- windows_x32
- linux_x32
This plugin is for Sublime Text 3. For Sublime Text 2, please use https://github.com/komsit37/sublime-q-2
To build numpy
The included numpy version should work for osx and windows 64bit, but if you need to build numpy:
- download python 3.3
- download http://sourceforge.net/projects/numpy/files/NumPy/1.8.1/
- run
python3.3 setup.py install
- numpy will be installed to your default python lib
- then follow steps here https://github.com/komsit37/sublime-q/issues/12