I'm using Sublime Text 2 for Rails development. I love the editor so far, especially its customizability. Currently I'm getting used to a 2-panel workflow where I have various Rspec files open in the right panel, and the corresponding views, controllers etc. open in the left panel. But when I open new files, they frequently open in the wrong panel (the one I'm currently working in), and I have to drag them over to the left or right manually.
Here's my question: when I open a file, is it possible to make the file open in the right panel if the file name has "_spec" in it, and in the left panel otherwise?
I know that's a pretty specific adjustment. I'd appreciate any tips.
Yes it is possible via a plugin. If you have some time, I'd spend a little bit of it investigating the sublime text api. I've thrown something together that should work. It's only minimally tested, and not very robust. Though I think it should work for your use case. If it doesn't you can use making it just right part of exploring the ST api.
import sublime_plugin
import os
class OpenLocationListener(sublime_plugin.EventListener):
def on_load(self, view):
file_name = view.file_name()
window = view.window()
num_groups = window.num_groups()
if file_name is not None and num_groups >=2:
if "_spec" in os.path.basename(view.file_name()):
if window.active_group() == 0:
window.set_view_index(view, 1, 0)
window.focus_view(view)
else:
if window.active_group() == 1:
window.set_view_index(view, 0, 0)
window.focus_view(view)
Save the above in your Packages/User folder as <some name>.py The name doesn't matter, as long as you save it as a python file.
As a side not, unless you are using an ST2 only plugin, consider upgrading to ST3. Many plugins that are under active development may only be ST3 compatible. I wrote the above in ST3, so that's where I tested, though I don't believe there is anything ST3 specific about it.
Related
Jumping on this lua-neovim bandwagon...Need help with Telescope, please.
In my old setup; I'd grab basic templates from my documents like:
<leader>gt :-1read ~/Documents/templates/
And then I just use vim's normal tab completion to get where I need to go, but with telescope's fuzzy search and preview window, this will go to the next level!
I can open my templates like this
lua require('telescope.builtin').find_files{ cwd = '~/Documents/templates/' }
I've tried several combos with :read and various brackets, to make it read the contents into the current file to no avail (just learning Lua now, so mostly just crash and bang methods)
I found this in the docs with vague mention to reading files
previewers.buffer_previewer_maker({filepath}, {bufnr}, {opts}) previewers.buffer_previewer_maker()
But I'm obviously missing something.
Ideally I'd want key combo in the mappings, that way I can open normally, or read it (bonus points if it inserts at the cursor) - along with the miriad of options already available.
mappings = {
i = {
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
...
["<C-r>"] = actions.READ_FILE_INTO_BUFFER,
...
Anyways, I've spent way too long on this, and I'm sure one of you Lua/Neovim Geniuses will have the solution!
Thanks!
say i have this line of code :
Object.Property.field;
Object.Property:FunctionName();
in all my sublime languages if i was to double click "Property" on either line, it would select just that word.
For some reason my lua/lua love2d syntax highlighting selects the whole line up to the ":"
How can I change this behavior, so it will only select the single word?
The reason this is occurring is because of a somewhat strange addition to the Lua Love plugin, which I assume you're using. You're using Sublime 2, so select Preferences -> Browse Packages... to open up your Packages folder, then open the Lua Love subfolder. There is a file called completions.py, which has this content:
#completions.py
import sublime
import sublime_plugin
import re
class LoveCompletions(sublime_plugin.EventListener):
ST = 3000 if sublime.version() == '' else int(sublime.version())
def on_query_completions(self, view, prefix, locations):
if self.ST < 3000 and ("lua" in view.scope_name(locations[0])):
seps = view.settings().get("word_separators")
seps = seps.replace('.', '')
view.settings().set("word_separators", seps)
Even if you don't know Python, the logic is pretty easy to follow. It sets the variable ST to Sublime's version, which is 3000+ if you're using ST3 (current build is 3061), and is 2221 (I think) for ST2. It then sets up an event listener (the process is always running in the background) checking to see if the Sublime version is less than 3000 (you're using ST2) and you have lua in your current scope (basically, your file is source.lua or source.lua.love, if you're using the plugin's language definition). If both of those are true, it removes the . character from your "word_separators" setting, which is defined in Preferences -> Settings-Default and can be overridden in Preferences -> Settings-User.
The word_separators setting controls what characters are considered to be word separators when double-clicking to select a word. Its default value is ./\\()\"'-:,.;<>~!##$%^&*|+=[]{}`~? so, for example, if you double-click on the foo part of foo-bar Sublime will only select foo, but if you double-click on the foo part of foo_bar Sublime will select the whole thing (since - is in word_separators). . is in word_separators by default, so double-clicking on foo in foo.bar will only select foo, which is expected behavior for most people, I would assume. However, this cute little plugin removes . from word_separators in Sublime Text 2, so in your case clicking on Property selects everything from the beginning of the "word" (the whitespace before Object) to the next word separator - the :, in the case of your second example.
OK, so we know what the problem is, how do we fix it? First, while you're in Packages/Lua Love, just delete completions.py altogether. There's no harm in doing so, and in fact it's actually causing harm by being there. Make sure you restart Sublime after deleting the file. Next, open Preferences -> Settings-User and add . back into the word_separators list, anywhere between the beginning and ending double-quotes. Save that file, go back to your source code, and double-clicking should once again behave normally.
Good luck!
EDIT
I submitted this pull request to delete the completions.py file from the plugin's Github repo, and it was just merged, so hopefully users in the future won't have to deal with this :)
I am trying out TYPO3's introduction package. For that I am using Xampp on my computer.
I have installed it in a subdirectory, but since it uses "real-url", I need to modify the generated links, so that instead of http://localhost/about-typo3/ I get http://localhost/subfolder/about-typo3/
I believe it must be done via "typo-script", and from what I have read on the Internet, this line should do the job :
config.baseURL = http://localhost/subfolder/
But I don't know where I should put it. I have tried different locations, but with no apparent effect.
So what I would like to know is : am I on the good path for what I need to do, and if yes, what should I try now ?
This is a bug in the 4.6 Introduction Package. 4.7 will ship with a correct version, so you might just want to go ahead and try the Introduction Package from 4.7RC2 (Preview Releases).
For now, just choose Template in the module menu on the left. Then use the dropdown to select Constant Editor. Now choose the page HOME in the pagetree on the middle.
Now use the second dropdown to select CONFIG. There modify the topmost setting Absolute URI prefix. Input your full domain without the last slash (/). That means copy your current URL from the browser and strip /typo3/backend.php. Now save with the little save icon in the top toolbar.
This will also invalidate all caches for you (because you changed the topmost template). No need to install extra extensions or to do this manually.
Alternative you can fix the actual bug. Go to template module and select the folder TypoScript Templates / page_configuration. Now select Info/Modify instead of Constant Editor and directly above the table page.config. The click the pencil left of Setup. Find the line absRefPrefix = {$config.absRefPrefix}/. This should be around line 62 (4.7RC2). Remove the last slash (/) from that line and save. Because you are not on the topmost template, you need to clear the cache. On the topright of your screen, you can find the yellow flash icon. Click it and select Clear all caches (red flash). Now go to you website again.
A general note about (config.)baseURL. This is more a hack, because it just tells the browser to behave as if the website would be at another place. The correct way is to create correct links in first place. You should use (config.)absRefPrefix instead. To make this work in auto mode, it must be completely empty (config.absRefPrefix =).
Do not use baseURL any more. The next Introduction Package will not have this setting.
Yet another note: If you use the config.absRefPrefix, you have to include the last slash (/). The only reason why you do not have to do so above (in the constants), is because it is hardcoded in the template and thus also preventing the automatic detection to work.
If you are using different hosts, you can use typoscript conditions in your root template:
# Default:
config.baseURL = http://www.example.com/
[globalString = ENV:HTTP_HOST=sub1.example.com]
config.baseURL = http://sub1.example.com/
[global]
[globalString = ENV:HTTP_HOST=sub2.example.com]
config.baseURL = http://sub2.example.com/
[global]
if you are using introduction package. there is Constant for set the base url
Go to 'Template' and 'Constant Editor.. you can find 'Domain name for Base URL [config.domain]' .. for setting base url
also you can put the
config.baseURL = http://localhost/subfolder/
on 'Info Modify' Setup field
hope will help you .. sorry for my bad english
I'm searching for a console code editor with CUA key bindings (ctrl+x, c, v etc.)
Right now i'm toying mcedit but i don't really like it. My desired features are:
* be fast
* CUA key bindings (ctrl+x, c, v etc.)
* toggle show line numbers
* find/replace/goto line
* bind custom keys to action( ctrl-shift-arrowdown to double the curent line etc.)
* nice simple vi-like interface (no pointless menus)
* be able to programatically extend it ...
etc.
There are a number, but most are strangely obscure & little-known. This surprises me -- I'd have thought a lot of people would have wanted this!
I have tried quite a few. These are the only 2 that I know of that are current.
Tilde is alive, maintained and has recent packages available.
http://os.ghalkes.nl/tilde/
There is also eFTE, enhanced FTE, which works well in my experience.
http://sourceforge.net/projects/efte/
You could use emacs with CUA-mode.
You probably have to configure it further to form it to your liking.
There are lots of extensions for key-bindings and it has a pretty powerful extension mechanism. If you get over the initial surprise that its all in lisp you might actually like it.
Try micro editor. See https://micro-editor.github.io/ .
Ctrl-C/V/X/Z/Y/F/S/Q are supported. Shift+Arrows for selection is supported. Syntax highlighting is present.
Another CUA editor, with menu and dialogs, is Turbo, which is written with TurboVision 2.0+Unicode: https://github.com/magiblot/turbo
i'm searching for a pretty print program (script, code, whatever) for Informix-4GL sources.
Do you know any ? Than you, Peter.
Have you looked at the IIUG (International Informix User Group) software archive? There are two pretty printers there (of indeterminate quality).
The other place to look would be the Aubit4GL site - an open source variant of I4GL. Again, I'm not sure that they have a pretty-printer, but it might be something they have (though a casual check doesn't show one).
I don't know if anyone is reading this post anymore, but the easiest way to get some kind of nice "pretty print" of 4gl code is to view it in the Openedge Developer Studio, then use ctrl-I to set indention. You can adjust indention in the editor settings by saying the length of "tabs". (default is 4, I use 3)
Then do a ctrl-shift-f to make all command words uppercase.
Next, you can condense the code a few lines by moving all the "DO:" statements up a line next to the "THEN" statement with this regular expression search and replace.
ctrl-f:
search "\s*\n\s*DO[:]"
replace " DO:"
make sure you click the checkbox marked regular expressions.
At this point the code is nice and tidy.
Do a ctrl-a and ctrl-c to copy it to the clipboard.
paste it in Outlook as an email without sending. Print it in color.