Is possible to change the positions of the tabs in vim? - vim

I was wondering if is there any way to change the place of the tabs. Anyone can help me about this? I would like to have vim as my favourite ide..:)

Check out help :tabm[ove]. Essentially you could do:
:tabm +N to move current tab N places to the right. Or :tabm -N to move N places left.

Vim is not an IDE, it's an editor. You won't turn it into an IDE, no matter how hard you try.
Anyway, read :h tabmove:
:tabmove 0
moves the current tab to the first position
:tabmove 2
moves the current tab to after the 2 tab
:tabmove
moves the current tab to the last position

What do you exactly mean by "place of the tabs"? The other answers have already shown how to move individual tab pages around.
If you're inquiring about where Vim places the tab labels, that cannot be changed; they will always be between the GUI menu and the windows. In GVIM, you can only "downgrade" the tab appearance from graphical to textual via
:set guioptions-=e

When using the tabline (with guioptions-=e), you can drag and drop tabs with your mouse.
There is a patch pending (but not applied yet as of Vim 7.4.1054) to expand this to the GUI tabs as well:
https://groups.google.com/forum/#!msg/vim_dev/LnZVZYls1yk/fj_Gz0vhnrsJ

Split Manipulation
Ctrl+W, R (Swap top/bottom or left/right split)
Ctrl+W, T (Break out current window into a new tabview)
Ctrl+W, o (Close every window in the current tabview but the current one)

Related

Vim to always only jump one row at a time [duplicate]

I can get the bottom of the window to display partial lines by setting display=lastline
Is there a similar option that would allow partial lines to be displayed at the top of a window?
Without this functionality, my vim still scrolls (down) by more than 1 screen line when the topmost file line being displayed is wrapped into multiple screen lines.
For example, in the following scenario, when I press C-E, my vim will scroll down by 3 screen lines. Is there a way to make it scroll by only 1 screen line such that only the first two words in line 1 are hidden, but the following 3 words are still displayed? This will be very useful for editing long paragraphs of text.
Note: I'm referring to the scrolling of the entire screen, not the movement of cursor.
------------------
1 abcdefg abcefg
abcasdfsa sdfsf
sdfc
2 adfadf
3 adfadf
4 adfadf
------------------
I don't think it is possible to do exactly what you want.
Here's the description I get when I type :help CTRL-E
CTRL-E
CTRL-E Scroll windows [count] lines downwards in the buffer.
Mnemonic: Extra lines.
Note that while it says it is scrolling the window, it also mentions that it is scrolling lines in the buffer. You really are scrolling only one (wrapped) line at a time.
I don't think there's another way around this.
I can get the bottom of the window to display partial lines by setting display=lastline
I think display=lastline is a false solution - you still scroll the same amount, you just have more visible.
The real way to solve this is to disable wrapping:
:set nowrap
Edit
Some related threads that show that a "scrolling via screen lines" feature is under consideration, but will take a while to be implemented:
http://vim.1045645.n5.nabble.com/Feature-request-Display-partial-paragraph-at-the-top-of-the-window-td1166809.html (4 years ago)
http://vim.1045645.n5.nabble.com/Scrolling-screen-lines-I-knew-it-s-impossible-td3358342.html (the beginning of this year. Same dev mentioned wanting to implement it: "Ben Schmidt")
For anyone reading this thread:
This thread on the Vi stackexchange offers a slightly hacky (but useable) solution to visual scrolling across wrapped lines.
Now there's a built-in option for this:
'smoothscroll' 'sms' boolean (default off)
local to window
Scrolling works with screen lines. When 'wrap' is set and the first
line in the window wraps part of it may not be visible, as if it is
above the window. "<<<" is displayed at the start of the first line,
highlighted with hl-NonText.
NOTE: only partly implemented, currently works with CTRL-E, CTRL-Y
and scrolling with the mouse.

Vim window resizing

I split my windows in Vim horizontally. But after I split, the new window occupies half of the original window size, I want to change this and make sure the new window occupies almost the entire old window.
Basically if I open three files using horizontal split in Vim, I should see three status bars at the bottom of the screen the third file occupying the rest of the screen. The files as I already know can be navigated through Ctrl+W+arrow keys. So if I navigate to second file now, I should see one status bar at the bottom and one status bar at the top.
Kindly let me know how to configure the same. I looked up online all I could find is options to dynamically change the size or resize, but I want static one-time config (for example, in vimrc or bashrc).
If you set the winheight option to 999, the current window occupies as much of the screen as possible, and all other windows occupy only one line (I have seen this called "Rolodex mode"):
set winheight=999
You can type in command mode :res[ize] +N or :res[ize] -N where N is the amount in which your window will grow or shrink respectively.
Go to point 6 (Window resizing) http://vimdoc.sourceforge.net/htmldoc/windows.html but the article has everything on windows management in VIM
Hope this helps!
You might prefer just using vim tabs, which work rather like how you described.
Try this:
vim -p file1 file2 file3
Then use :tabn and :tabp to cycle fwd and back through the tabs.
I also like this mapping in .vimrc to use ctrl-l and ctrl-h to cycle fwd and back respectively:
noremap <C-h> :tabp<CR>
noremap <C-l> :tabn<CR>
Command for split window:
:[N]sp[lit] [++opt] [+cmd]
Where N is height of new window. Default is to use for half the height current window. Same thing for vertcal splitting:
:[N]vsp[lit] [++opt] [+cmd]
N is width for split window.
And so on:
[N]new, [N]vnew
For details read the
:help split
But I can't understand why you do not use buffers?

How to jump to the rightmost window with just one keystroke?

I found the window manager in vim is quite powerful. We can use it to split the window to whatever we want it to be. But when the numbers of the windows comes to more then 4, it will caused one problem: it's quit hard to jump to the rightmost window. Because the rightmost window is used to display taglist in my vim. I don't like the way that type CTRL+w for twice or more times to jump to the rightmost window. Is there a more easier way to do it?
:nmap <C-\> <C-w>200l
then you press ctrl-\ will let you go to the most right window.
actually you don't need to press c-w many times. if you have 10 windows opened, and now you are in 3rd window, you just type ctrl-w 10 l. to go to the right most window.
from help:
CTRL-W_l| CTRL-W l go to Nth right window (stop at last window)
you just need give a N
If the previous window was TagList, you can use <C-w>p to jump to it.
You can also use <C-w>b to jump to the last window at the bottom-right.

Vim/MacVim: when I scroll with mouse, the text cursor moves too!

I've been getting used to Vim/MacVim for the last few weeks. One of main problems I seem to be having is when I scroll around using the mouse (especially when I'm trying to select large portions of text) the text insertion cursor moves too and doesn't stay where it was (like in TextMate for example). This means I've selected a large piece of text, when I scroll back up to review my selection the cursor will move which messes with the selection that I've made.
I do realise I should get used to text selection with visual mode, and I am one bit of a time, but sometimes it's the best tool to use the mouse.
Is there a way of fixing this behaviour?
:help scrolling tells you:
These commands move the contents of
the window. If the cursor position is
moved off of the window, the cursor is
moved onto the window (with
'scrolloff' screen lines around it).
So basically I would say that it is not possible to leave the cursor where it was when you are scrolling. The cursor is always visible in your window, and therefore your visual selection will extend.
Probably you would like to xnoremap <ScrollWheelUp> <esc><ScrollWheelUp> and same for ScrollWheelDown. Use then gv to restore your selection.
I made a screencast about Vim's changelist and jumplist which addresses the issue of Vim's cursor always being on screen. The changelist maintains a list of all of the places in your document where you have made an edit. You can move back and forward through the list with the commands g; and g, respectively. Or if you want to put your cursor back on the last place where you made an edit and go into insert mode, just press gi.
As Alois Cochard pointed out, the o key is very useful when you are in visual mode. It moves the cursor between the start and the beginning of your selection. So if your selection is larger than your screen, it will move you from one end to the other.

How to jump back to NERDTree from file in tab?

I usually:
Choose the needed file.
Open it in a tab(t character, by default).
But how I can jump back to NERDTree to open one more file in a tab?
Temporary solution I use now in my .vimrc file:
map <F10> :NERDTree /path/to/root/of/my/project
But it's not very useful to start navigation again and again from the root directory.
Ctrl-ww
This will move between open windows (so you could hop between the NERDTree window, the file you are editing and the help window, for example... just hold down Ctrl and press w twice).
Ctrl+ww cycle though all windows
Ctrl+wh takes you left a window
Ctrl+wj takes you down a window
Ctrl+wk takes you up a window
Ctrl+wl takes you right a window
NERDTree opens up in another window. That split view you're seeing? They're called windows in vim parlance. All the window commands start with CTRL-W. To move from adjacent windows that are left and right of one another, you can change focus to the window to the left of your current window with CTRL-w h, and move focus to the right with CTRL-w l. Likewise, CTRL-w j and CTRL-w k will move you between horizontally split windows (i.e., one window is above the other). There's a lot more you can do with windows as described here.
You can also use the :NERDTreeToggle command to make your tree open and close. I usually bind that do t.
If you use T instead of t there is no need to jump back because the new tab will be opened, but vim's focus will simply remain within NERDTree.
You can focus on a split window using # ctrl-ww.
for example, pressing:
1 ctrl-ww
would focus on the first window, usually being NERDTree.
Since it's not mentioned and it's really helpful:
ctrl-wp
which I memorize as go to the previously selected window.
It works as a there and back command. After having opened a new file from the tree in a new window press ctrl-wp to switch back to the NERDTree and use it again to return to your previous window.
PS: it is worth to mention that ctrl-wp is actually documented as go to the preview window (see: :help preview-window and :help ctrl-w).
It is also the only keystroke which works to switch inside and explore the COC preview documentation window.
ctrl-ww Could be useful when you have limited tabs open. But could get annoying when you have too many tabs open.
I type in :NERDTree again to get the focus back on NERDTree tab instantly wherever my cursor's focus is. Hope that helps
The top answers here mention using T to open a file in a new tab silently, or Ctrl+WW to hop back to nerd-tree window after file is opened normally.
IF WORKING WITH BUFFERS: use go to open a file in a new buffer, silently, meaning your focus will remain on nerd-tree.
Use this to open multiple files fast :)
You can change the tabs by ctrl-pgup and ctrl-pgdown. On that tab you came from the NERDTree is still selected and you can open another tab.
In more recent versions of NERDTree you can use the command :NERDTreeFocus, which will move focus to the NERDTree window.
gt = next Tap
gT = previous Tab
if you want you can enable the mouse support editing ~/.vimrc file.
put set mouse=a
after that you enable files click in NERDTree.
All The Shortcuts And Functionality is At
press CTRL-?

Resources