sublime text: how to go to previous position in the same file - sublimetext3

In sublime text, I can see using Alt - takes to previous cursor position.
But it also takes to other files. I want to go to previous cursor position in the current file only.
What can be done for this

Related

Select entire text from current line in Linux using a keyboard shortcut

I've been using Ubuntu/VS Code for a week and I've been struggling with text selection.
In my mac if I want to select text starting from a position until the end of the text I can easily do that with Command + Shift + arrow, but I just can't figure out how to do the same in Linux (Ubuntu), CTRL + Shift only works selecting word by word, and sometimes we just want to select an entire row or the entire text from the current position.
Appreciate the help
Put your courser on the point you want to start. Press Shift+End for the end of the line.
If you want to copy the whole line from first to last simply place the cursor somewhere in that line and hit CTRL+C.
Press Home key to get to the start of the line.
For Selecting multiple lines, use Up/Down key.
The best way is, Put your courser on the point you want to start. Press Shift then click the point you want to end using mouse/touchpad.
I tried the CTRL-C suggestion above without any result. (Mint 19.3 Cinnamon)
Accidentally, I found found that the left mouse button, triple-clicked, selects (highlights) the entire row the cursor is in. [Not seen that documented!] I suppose an expert on xdotools might write you a script for that.
Or position the cursor at the starting point and enter
Ctrl+Shift+End (or repeated right arrow) for a document,
Shift+End (or repeated right arrow) for a single line.

How to remove text from before a cursor to start of line in visual mode in vim?

I've recently begun challenging myself in VIM and slow to get around still. Suppose I have the following:
1 ewdawdawdeditor you can scroll the
1 page, move the cursor, delete lines, insert
2 characters, and more, while seeing the
3 results of your edits as you make them.
My cursor is on 1,1 and after vfe its on 1,10.
How can I delete the text before the cursor to the beginning of the line without pressing hd?
If your goal is to simply select from the beginning of the line up to but not including the first "e", you can use vte instead of vfe. Then you can press d to delete.
Alternatively, you can delete without entering visual mode with dte.
To the extent of my knowledge, I don't think there is a way to delete everything in a visual mode selection excluding the last character.
If the cursor is somewhere at the middle of a line and you want to delete from the the beginning until the cursor just go with :
d^
If you really want to go visual before deletion, you can use :
v^d

How can I easily edit after finding text in Sublime Text 3?

Whenever I do a sublime find, at some match I wish to add the text. But is there a shortcut to edit without moving mouse and clicking the text (to bring cursor to that location)
Example gif (issue I'm facing) - https://imgur.com/wTe3vcA
Just press Esc after finding your text.

Paste to end of the file in VIM without moving cursor

In a text document, I'm [visually or otherwise] selecting several lines, cutting them with d... I'd like to paste these lines to the end of the file without moving the cursor. Is there a relatively simple way to do this?
Use the Implicit Mark from Last Jump
You can use the implicit mark (e.g. ') to return your cursor to the location it occupied just before the last jump. For example:
Gp''
This will (G)o to the end of the file, (p)aste the contents after the last line, and then return to your position at the time you typed G.
There are a few ways:
Marks
Set a mark, do your paste, then jump back to the mark
m':$pu<cr>``
Visual mode
Visually select your lines, copy them, append, and then restore visual selection (optionally delete)
y:$pu<cr>gv
Append to the file
Visually select your lines, use :w to append to the file, and then reload the file. (Note: will move the cursor to the start of the visually selected lines)
:w >><cr>:e!
Create your own command/mapping
You can create your own command and/or mapping that will use winsaveview() and winrestview() to append then restore the cursor.
You can define a mapping which marks the current location, pastes at the end of the buffer using :$put then returns to the original cursor location using the mark.
This works because :put allows a line number prefix (the last line being representable as $). From :help put:
:[line]pu[t] [x] Put the text [from register x]
This would map it to <leader>p:
:nnoremap <leader>p :mark '<cr>:$put<cr>`'
It sets the ' mark at the cursor, pastes at the end, then returns to the ' mark with `
Depends on how you mean "without moving the cursor".
This will paste at the bottom of the current file and then allow you to continue where you cut the lines from.
split window with :split
move to bottom with shift+g
paste with p
close the duplicate split view (zz or :q)
If you dont like the split view, you can use the ctrl+o to jump back after G
move to bottom with shift+g
paste with p
jump back with ctrl+o

Vertical line alignment when opening new window in vim

How do I keep vertical alignment when opening a new window (split) under current one in vim?
When I edit a file, some lines are visible (say 1-20). Once I open another window the visible lines change to something else (say 5-15). I would like to keep the original window vertically aligned, meaning see lines 1-11 in my example.
The "vertical alignment" changes because Vim is trying to keep the line that your cursor is currently on in view. The simplest way to do what you want is just to press H before you do your split. H moves your cursor to the top line of the window, so when you split the viewport won't have to change to keep your cursor in view.
This will move your cursor of course, but you can just hit `` to return to the mark that was set when you pressed H.

Resources