Sublime Forum

Some questions

#1

I’m a relative newbie to st2 and st3, great editor… thanks for the work (happy to purchase).

Couldn’t seem to find info on these questions after much searching and playing… any help would be appreciated:

ST3 questions (build 3021):

  1. when scrolling down a line at a time when my cursor hits screen bottom it then “jump scrolls” to screen middle

    • can this be disabled? ST2 doesn’t do this for me, it just scrolls one line down at the bottom as desired leaving cursor at bottom
  2. I read about Goto Definition and Goto Symbol spanning files in my project (great)…but I don’t see options (at all)
    with either Perl or Python code … how do I enable them (or troubleshoot them not being visible)

More general question. A common thing I do in VIM is something like this in command mode:

a) position cursor at line I want to cut to
b) ma (places mark ‘a’ at a line in a file)
c) move cursor down a number of lines (for example, 20 lines down)
d) d’a (deletes to mark a, includes current line and line mark ‘a’ is on, also captures delete into “yank” buffer, simple ‘p’ puts it below the current line)
-> one can extend this and delete into a buffer, "ad’a (delete into buffer ‘a’ up to mark ‘a’)
-> one can instead ‘yank’ and leave it via y’a or yank into a buffer "b’a or "by’a (yank into buffer b current line and all lines to mark a line)

I’ve requested these features from the Vintageous plugin folks (very helpful, it’s on their list). In the mean time I’m
curious how one would do this “sublime native” (without the mouse)… very simple, line based cut or delete to mark
and then paste (perhaps with different named buffers but that is secondary, just one buffer or the system clipboard
is fine as well, I used a “stacked” clipboard via copy paste pro).

I can’t find an easy line-based way to do this (cursor position on line seems to matter in the methods I’ve tried, but I
don’t want it to matter… I just want the entire set of lines yanked or deleted. I’ve tried this for instance in my own
key bindings:

{ "keys": "super+k", "super+m"], "command": "set_mark" },
{ "keys": "alt+m"], "command": "set_mark" },
{ "keys": "alt+y"], "command": "select_to_mark" },
{ "keys": "alt+d"], "command": "delete_to_mark" }

]

And then I expect to drop a mark, alt+m, move down some number of lines and then select to mark or delete
to mark. Doesn’t seem to fly… I can set the mark (and see the dot on the line) no problem… but can’t seem
to delete or yank (ideally I’d like to delete and yank at the same time like in vim). Toss me a bone if you can.

I’m working to turn Sublime into my main editor going forward as it’s just amazing in many ways… but copy/paste
is something I could use a hint or two at (I’ve read lots of google search results and just haven’t found an easy
way to emulate this).

Aside: in ST2 VIntage mode this does’t work either… although it’s “close”, I can run 5"ayy for instance to
yank 5 lines into buffer a from my current cursor position… and I can place a mark via “ma”, and move
to it via 'a today but I can’t cut/yank to it yet via d’a for instance (or with named buffers).

Thanks again! Hope to speed up my keyboard based workflow w.r.t cut/yank/paste

Erik

0 Likes

#2

[quote=“ebrady”] 1) when scrolling down a line at a time when my cursor hits screen bottom it then “jump scrolls” to screen middle
- can this be disabled? ST2 doesn’t do this for me, it just scrolls one line down at the bottom as desired leaving cursor at bottom
[/quote]

Maybe setting this in your user preferences:

"scroll_past_end": false
0 Likes

#3

Thanks for the suggestion… but I’m afraid that setting doesn’t work:

For the scrolling thing I’ve played a bit more… it is likely Vintageous related (vim
compatibility in ST3). If I use the arrows to move the cursor and I’m in “command mode”
it does the jump scroll thing when I hit the bottom of the screen… but if I’m in insert
mode then it does not, it just scrolls down one line at a time when I hit the bottom
(leaving the cursor at the bottom). On that one I’ll ping the Vintageous folks (for now
I’ll disable Vintageous and enable Vintage and VintageEx which do not have this issue).

Still not clear on the keyboard cut/paste item or the new ST3 Goto features not
showing up.

Erik

0 Likes

#4

The named marks is something that would (and the associated actions) would be something that would have to be implemented in a plugin. I think the GoTo feature you are looking for is bound to “ctrl/cmd+shift+r”. Where ctrl/cmd is platform specific.

Positioning the cursor should be doable. I’m surprised it isn’t built into Vintageous. The following is a snippet from the Vintage keymap file (or is this not the behavior you were looking for?)

{ "keys": ":"], "command": "show_overlay", "args": {"overlay": "command_palette", "text": ":"}, "context": {"key": "setting.command_mode"}] }
I would think the copy/cut to marks is something that could be implemented. Of course, I make the assumption that the marks are stored as a region, you should be able to create a new region from the cursor to the mark (or the full lines), extract the string (potentially erase it for a cut action) and place it on the clipboard.

0 Likes

#5

Thanks for additional feedback! First a note on what I’ve found so far:

a) the GoTo definition gets disabled when I created a ‘Library/ApplicationsSupport/Sublime Text 3/Packages/Default/’
directory (even an empty directory causes the ‘Goto Definition’ to be grayed out, not sure why), and
it’s gone/missing completely when there’s content in Default/ (ie: Goto Definition and Goto Symbol in Project
both vanish from the menu… it may be related to some content I have in Default, I haven’t jumped in to fully
figure out which bit causes the menu entries to vanish completely yet). NotE: I may have copied some of this
over from ST2 (as I was testing ST3) so, to resolve this issue I simply removed the ‘Default/’ subdirectory
(completely) and now these Goto capabilities work in Sublime Text 3 (hurray)
- aside shift-cmd-r maps to the find symbols across the project… but it only worked correctly
once I tweaked the above, i also found plugins overriding the keymap so created my
own so I could kick that off easily from the keyboard (as well as the jump to/back)

b) As far as keyboard “line based” cut and paste I do have a request in to the Vintageous folks to do
more here (Vintage could do more as well as far as cut/delete to mark, neither handles it even
though both handle marks and have basic named or unnamed cut/yank buffer support). As you
indicate some plugin work will help on the vim compatibility side (Guillermo has indicated this
is on the list for Vintageous, as are some additional items I’ve noted via github, thanks!).
-> in the mean time the mentioned mark, delete to mark and yank to mark sublime native
capability “sort of works”. For delete it’s pretty solid but I don’t know if the deleted
text is available in a buffer (at least it does delete full lines)… if that deleted data was
in some buffer I can paste easily that would be nice but haven’t figured that out). If I
instead try the select to mark, ie:
{ “keys”: “alt+y”], “command”: “select_to_mark” },
then it’s a little sketchier… doesn’t always select full line contents on the 1st and
last line (but I can do the select and see what it got and what it missed and at least
sort of correct/shift what is selected near the mark… to try and get all I need selected…
then hit cmd-c to copy it to my clipboard, then delete to mark and get “most of it”… just
has to be a better keyboard way ala ‘vim’ as described below (eg: ma to put mark ‘a’, d’a to
delete current line up to and including the line I marked and that deleted buffer is available
to paste in via a simple ‘p’ … so quick/easy). If I want to change files with the lines and paste
them into a different file (or perhaps cut/paste a few sections separately) then I can cut into
named buffers as described in the original post… very easy, no mouse. Looking forward to
Vintageous/Vintage improvements.
-> I need to come up to speed on the plugin mechanism (and python) then perhaps
I can do more for myself here… “on the list” (the list is always long it seems) :wink:

c) As for the “jump scroll” feature I opened a ticket w/Vintageous on that
-> the owner mentioned it was a known issue but was happy to have an official ticket to track
it until it’s fixed

d) I noticed that the Emmet plugin takes over some key bindings like ctrl-d … so I’ll have to put
that in my user keymap so it does the vim based page down… just odds and ends like that I’m
starting to figure out.

One step at a time. I can’t say that I fully follow your cursor positioning comment above… but, as
above, the Vintageous plugin does have a ticket open for the cut/yank to mark capability and indicated
it was “on their list” (so it certainly is possible to do within a plugin and, as mentioned in my original
post most of the capabilities around this already work, just not cut/yank to mark yet). Soon.

I’ve noticed some other funny things like moving between files I won’t always be placed where
my cursor is (ie: I might be at the top of the file but if I move left or right using vim mappings
the window then “jumps” to wherever my cursor was left in the file at that time… should go
right there to begin with).

Anyhow… the remaining outstanding item is better line based cut/yank and paste via the keyboard
I guess… looking forward to Vintageous improvements (or Vintage).

0 Likes

#6

Sorry for being unclear. One of the API calls (view.sel()) returns a RegionSet. I was just getting at the fact that we could create a region using the cursor position (a result from view.sel()) and the mark location. You could then call view.line() on that region, which would return a new region covering the lines from the current cursor to the mark. From here you could perform the erase, yank, cut, etc operations. This would be something that the Vintage/Vintageous plugins would implement. Of course, if you want to dive a bit into plugin development, you can try it also. :wink: I’m sure guillermooo would welcome pull request.

0 Likes

#7

I see now what you meant, thank you. Yup, I’ll need to work towards tweaking plugins more coming up,
should be fun. One step at a time.

Beyond that I’ve just opted to work around it a bit with visual mode… I can hit ‘V’ to kick into visual mode
and select the lines I want via ‘j’ (up) and ‘k’ (down) and via using ‘o’ to flip which “side” of the visual section
I want to adjust while forming up the selection… decent… then, with the selection highlighted, hit ‘y’ or ‘d’
to yank or delete it (or even p to paste over it while yanking the old text if I need to). Additionally use of
buffers here works well, ie, steps:
step 1) V
- line by line visual mode (use ‘v’ for character based selection)
- move cursor around with j and k to select lines of code, along with o to adjust top/bottom of selection
step 2) d or y (or p or c)
- to delete or yank the selection (or paste something already buffered over it or to change it)
- if I want to delete into buffer ‘a’, use "ad or to use the system buffer "*d

That should get me by til cut/yank to mark flies.

Anyhow, slowly figuring out what might work best … thanks again!

0 Likes

#8

Quick update… Guillermo updated Vintageous with a version of the delete/yank to mark functionality (clone the latest repo and you’ll see it). Just a note that it is more character based vs native vim which is more line based (i.e.: the mark is on a specific character on a line, not on the line itself). It’s actually kind of cool in that it gives one more control in some ways and, if one marks at the beginning of a line one can then delete to that specific line, all of the line (ie: if one deletes from below the marked line to emulate vim one would go one line below the section you wished to delete and get into the left margin, then hit d’a and it would blast all lines above up to and including the marked line… as vim would do… for vim though one would hit d’a from on the line to delete from vs one below… but, hey, “close enough”… and we get the character flexibility).

Anyhow, I really like this implementation as the character based level of marking gives greater control in some ways. The mark on a character (vs a line) is also quite flexible as one can put a mark, change files and then pop back to that mark in that orig file by a simple 'a to go to mark ‘a’ for example). Takes you to the file, to the character you marked. Very cool.

Great stuff, thanks to the Sublime community on this one. I’ll keep having some fun and we’ll see what else pops up. Some offhand things are around the ‘:1’ to go to line 1 but one can hit ^g1 and get the same thing. Other items like 1G to go to the 1st line seem to be a little broken at the moment but that’ll improve (G to go to the bottom of the file does work). Improving day to day. :smile:

Erik

0 Likes