When splitting Vim window horizontally, contents of the "old" window are scrolled so as to preserve relative cursor line position. This happens even for small "helper" buffers, like quickfix or preview window.
The text movement caused by this becomes annoying when a split is repeatedly opened and closed - e.g. preview window used by completion plugin. Is it possible to disable this feature, and don't scroll old window when splitting (unless it's necessary to keep cursor line visible)?
Example - current behavior:
+--------------+ +--------------+
| a | | b |
| b | copen | c (cursor) |
| c (cursor) | --> | d |
| d | +--------------+
| e | | (preview) |
+--------------+ +--------------+
Desired behavior:
+--------------+ +--------------+
| a | | a |
| b | copen | b |
| c (cursor) | --> | c (cursor) |
| d | +--------------+
| e | | (preview) |
+--------------+ +--------------+
I reached this question when searching for a solution to this problem myself. I couldn't find a good solution and it really bugged me so I ended up writing a small vim plugin that will solve this.
https://github.com/gillyb/stable-windows
I think it does exactly what you want it to do. I only wrote it recently, so if there's any bugs feel free to open an issue and I will try to fix them.
Hope it helps! :)
Try something like
map <F12> mcHmh:split<cr>'hzt`c
store position in c mc
H move to top
store the position to h mh
your command here split for example
got to h 'h
put this to lien to top zt and got to c
Related
There is the grid layout in vs-code, and there is the terminal panel. Is there a way to combine both?
Lets say I want this :
--------------------------------------------------------------
| | |
| | |
| | |
| | something |
| | here |
| editor here | |
| | |
| | |
| |---------------------------|
| | |
| | |
| | terminal |
| | here |
| | |
| | |
| | |
--------------------------------------------------------------
I know we can put the terminal on the right, but I do not know if we can put it in the bottom of the right column. It works with other panel though, like editor.
To my best understanding, you cannot put the whole terminal panel (thinking of the combined: problems, output, debug console, terminal, ... group) in the grid layout.
However, you can put individual terminal shells into the editor and they will behave like opened files, able to be moved between editor panes.
After you have opened the terminal panel, you can drag and drop the shell's name (located just left of the little + sign where you can create a new terminal. It will have a name like bash or any other shell you are using) into the editor.
To make it easier, there is a setting for terminal.integrated.defaultLocation where you can specify the value to be editor. You split the editor panel as you see fit and then press workbench.action.terminal.new (default keycode is Ctrl+`) and you terminal will appear in the selected grid section.
I'm working in a project with lots of files and switching between different tasks. And having a lot of files open at once clog the tabs in the panes (and my brain). So therefore I would like to be able to switch out all my panes/views much like switching workspace in Linux. And when I switch back it remembers the files/views/tabs.
In short: ability to toggle between this:
Layout 1 Layout 2
---------------------------- ----------------------------
| | | | | |
| file a | file a2 | | file b | file b2 |
| (+3 tabs) | | | | |
| | | | | |
| | | | | |
| |-------------| | | |
| | file a3 | | | |
| | | | | |
---------------------------- ----------------------------
Does Sublime 3 has this functionality or is there a package that can help with this?
Here is detail explenation for layout creating in sublime text : example
My suggestion is to create those two layouts and put key shortcut for both.
Install chain of command plugin. Create key shortcut for mulitple commands :
1. set layout 2
2. move focus to group 1
3. open "file b" by name [plugin]
4. move focus to group 2
5. open "file b2" by name [plugin]
Do same thing for layout 1 scenario. Here is example how to create plugin for opening file by name how-to-open-file-using-only-keyboard-in-sublime-text . You need to modify some part of that plugin because it use input dialog.
I have four windows like this:
| | | |
| A | | |
|_________| C | D |
| B | | |
| | | |
So, how can I change them into this way?
| | |
| A | C |
|_________|______|
| B | D |
| | |
the
ctrl+W/J/K/L
thing is always moving the window to the far other side, I can't use them to do this.
Thanks!
what I can think of is two steps:
move cursor to C, press C-W c to close the window
move cursor to D, press :sp #<enter>
The idea is, close one window(buffer), and reopen it in right place (by sp or vs).
glad to know if there is easier way.
In Vim I tend to open buffers in new vertical splits (with the occasional horizontal split). I keep my code to 80 chars wide, so this works pretty well on large monitors.
I often end up with this window arrangement:
---------------------
| | | | |
| | | | |
------ | A | B |
| | | | |
| | | | |
---------------------
At four or five columns wide, it can start getting a bit too narrow, so then I want to move the windows around so it looks like this:
----------------
| | | A |
| | | |
------ ------
| | | B |
| | | |
----------------
As far as I know, this is impossible to do by moving the windows in Vim.
The only way to get that window arrangement I've found, is to close window A, and then re-open A as a new horizontal split from window B.
Is that correct, or is there a way to move/re-arrange windows like that in Vim? Maybe a plugin?
I'm yet to find anything, so I thought I would ask because I find the opening/closing of windows anoying and breaks my flow.
FWIW, I find the Ctrl-W + J / Ctrl-W + K shortcuts useless, because they make the new horizontal split as wide as the whole screen, rather than splitting with the neighbouring window. I.e. Ctrl-W + J would give me this:
----------------
| | | |
| | | |
------ | A |
| | | |
| | | |
----------------
| |
| B |
----------------
Which is generally never what I want.
If anyone has some ideas, let me know!
There's a plugin that can do exactly what you want. Here's the link : https://github.com/fabi1cazenave/suckless.vim.
I try to draw a class diagram using Vim.
I fill the editor window with white-spaces.
Type :match SpellBad /\s/ to highlight all the white-spaces.
Ctrl+Q to select vertical white-spaces.
Shift+I to insert Bar(|) and then Esc
...........................
v+l +... + l to select horizontal white-spaces
But I don't know how to change all selected horizontal white-spaces to underscore(_).
I have to hit _ serval times.
When comes to long horizontal line, it's bad.
___________ ___________
| | | |
| BaseClass |/__________| Client |
|___________|\ |___________|
/_\
|
|____________________________________
| | |
_____|_____ _____|_____ _____|_____
| | | | | |
| SubClass1 | | SubClass2 | | SubClass3 |
|___________| |___________| |■■■■■■■■■■■|
I want a quick method to do this.
Select it -> Change it -> Done!
Maybe map F6 to do it.
Thanks!
After everything you want to change is highlighted, type r_.
There are plenty of tools for making ascii diagrams, and converting them to graphical UML. Why don't you try one of those?
e.g.
http://www.jave.de/
http://ditaa.sourceforge.net/
http://www.diku.dk/hjemmesider/studerende/firefly/stud.html