Is there a way to make Emacs preserve my cursor's horizontal position, when going up and down between lines of varying widths in a file?
I'll explain what I mean by example. Say I have 3 lines of text:
1: ------a
2: --b
3: --c---d
Say the cursor is at the position marked above by a. If I move down a line, the cursor will be at b. If I move down again, it will be at c. But I actually want to end up at d.
Is there a way to make Emacs do that automatically, so that I can go from a to b to d just by pressing the down arrow twice? Emacs would have to remember my horizontal position from my most recent horizontal movement, and try to restore that horizontal position each time I move vertically.
Customize user option goal-column to nil.
(You can also use command set-goal-column anytime to set goal-column to the current column.)
Related
Let's say I want to place hyphen at the end of each line. I know I can do that by pressing Shift+Alt button in windows(to enable multiline cursors) and then jump to the end of line. (shown in the image below)
However, I want to place the cursor(and therefore hyphen) at the same position. In other words, I want hyphen to be below each another. Here is the pic of what I want -
Is there anyway to do this in vscode using multi-line shortcuts ?
Why do I want this ? To increase readability of my code.
The default behavior is that Emacs keeps scrolling the last line to the center of the frame. How can I keep the last line at the bottom of the frame when I scroll using the mouse?
(setq scroll-conservatively 101)
Here is the information from the *Help* window produced by describe-variable:
scroll-conservatively is a variable defined in `C source code'.
Its value is 101
Original value was 0
Documentation:
Scroll up to this many lines, to bring point back on screen.
If point moves off-screen, redisplay will scroll by up to
‘scroll-conservatively’ lines in order to bring point just barely
onto the screen again. If that cannot be done, then redisplay
recenters point as usual.
If the value is greater than 100, redisplay will never recenter point,
but will always scroll just enough text to bring point into view, even
if you move far away.
A value of zero means always recenter point if it moves off screen.
You can customize this variable.
When I start a rectangular selection (C-x SPS), firstly, a thin line appears at the side of the rectangle which shifts lines to the right.
Is there a way to make rectangular selection seamless?
The thin line is put "on purpose" to visually show where is the empty rectangle. We could make it optional (in which case the 0-width rectangles would simply not be displayed). Please use M-x report-emacs-bug since that's where this discussion should take place.
I have several items that I want to line up. The Width and Height of all fields match. Usually I just use the Align, but it's making it worse. My out of line field which is slighly lower, moves way up, way out of line (with align tops)
So I tried using the Size and Position to set it manually. Several objects have a Y of 0.056, but my last one has 0.061. I change the last one to 0.056 and save it. It doesn't appear to be different, and when I look at it again, it's still 0.061. (When I used align, it went up to 0.028!)
I do NOT have Snap to Grid set (my grid size is 0.083). (Nor does turning on Snap to Grid make them align.) The fields have exactly the same formatting. But unless I can magically make them align by hand, they refuse to align. Why?
You've already done a lot of the regular troubleshooting steps. One more ting that I sometimes do is to select all the fields I want to align, then use the arrow keys and move them up into the section above and then back down into their original section. That usually puts them all into the 0 position. If it dosn't work with all of them selected, try each one separately.
In Vim I can move a split around. For example, if my window was split in two horizontally, with the topmost split split vertically (3 splits in total) I could move the top-right split to the right to become a vertical split taking up the entire vertical space.
Is this kind of rearrangement possible?
Update: I know resizing is possible, I'm looking to move though. I get the feeling this is not supported by Emacs.
You may be interested by C-x + when you have more than 2 windows. It rearranges equally the windows on the frame. It's convenient for example when you do two C-x 2 in a row and want to have the windows to occupy the same space on the frame.
No, not by default. What you have to play with is basically C-x 0, C-x 1, etc. Look in the Emacs Wiki for extensions that may or may not do what you're looking for.
FWIW, if you are running within a GUI, then you can precisely re-arrange window sizes quickly and easily with the mouse. This isn't quite the same thing as you're asking for, but may be a handy alternative in some cases.
You can click on any non-'active' area of the mode line (such as the buffer name) and then drag it up or down.
Dragging side to side is more fiddly. You must click on the exact border between the two mode lines, and then you can drag left/right.
For your specific example, I don't believe that is supported. AFAIK you can only reorganise the window splits within their existing 'parent' window (the upper split in this example). To make the upper-right window fill the vertical space you would either remove the bottom window with C-x 0, or use C-x 1 to remove all other windows, and then re-split them in the desired manner.
(Tangentially, I've often thought a custom library to 'rotate' the window splits would be a nice thing to have.)
I believe that the window resize commands are built in to window.el, from emacswiki the functions you want documented are:
shrink-window-horizontally ; C-x {
enlarge-window-horizontally ; C-x }
enlarge-window ; C-x ^
shrink-window ; not bound on my system
The comments are what they are bound to on my system, but I don't know if I did that myself.
All of them take a prefix argument, the number of lines to enlarge/shrink. The last two default to vertical.
As far as I know you cannot create a new window that runs the length or width of the screenfrom a window already split in that direction. Buffers remain open if you close the windows though so you can remove windows and then split them in the configuration you want. Then change which buffer is displayed in the window you are standing in by pressing C-x left arrow or right arrow.
I should add that this answer is regarding "vanilla" emacs, there is probably a way of doing what the OP asks if you really want to. It's emacs after all.