I would like to duplicate the current buffer, which will act the same way only that I will use the rtl command on it:
:set rightleft
Except that the buffers will be the same, if I scroll down in the original one the second will scroll too and etc.
Is it possible in vim without any plugins?
Yes,
just split it
:sp or :vsp and then use the following:
:windo set scrollbind
windo will send the command to every open windo see :h windo
and scrollbind is what you are really looking for again see :h scrollbind for more
The rightleft or rl command is local to the window, so you can view the same buffer in two different windows with and without rl
Related
I.e. is it possible in vim to edit large file in several simultaneously opened tabs in the following way: first part of text (that fill all vertical space), second - in the second pane, and so on.
if it is not possible in vim, maybe it's feature is implemented in other editors?
Synchronizes two vim panes
Lets say your window is 20 rows, then
:vsplit // splits window into left and right panes
^w^w // focuses right pane
20^e // scrolls right pane down 20 rows
:windo set scrollbind // syncronizes both panes
^w means press and hold CTRL and then press w. Likewise for ^e
:windo means :set scrollbind in all open panes
Implement it in a function
Wraps the above commands in a function and binds it to [
function! SyncScroll()
vsplit
execute "normal! \<c-w>\<c-w>" . winheight(0) . "\<c-e>"
windo set scrollbind
endfunction
nnoremap [ :call SyncScroll()<cr>
You can add the above function and mapping to your vimrc with :e $MYVIMRC and reload it with :source $MYVIMRC
ref:
vim
docs - scrollbinding
wiki - scrollbinding
I think you're looking for the MPage plugin. You probably want to install the latest version from DrChip's page.
I want to show all buffers' names on statusline(I use powerline). And I hope current buffer can be highlighted, while others are not. When I use :bn or :bp it highlights the changed buffer. How can I make it?
I don't know how to do such a thing with powerline, however I have come across vim-buftabline which does what you ask but with the tabline instead of the statusline.
Personally, I would forget doing this in the statusline or tabline, because it is very easy to run out of space on either line. I would also stop using :bn/:bp and just use :b instead to jump directly to the buffer in question.
Behold the power of :b:
Uses <tab> completion
Use <c-d> to list out completion
Use partial file name. e.g. :b foo. Works great with <tab>.
Globbing. e.g. :b foo*bar or :b foo/**/bar
Might want to use 'hidden' via set hidden
Split variant of :b is :sb.
Also accepts a buffer number
A common mapping:
nnoremap <leader>b :ls<cr>:b<space>
For more help see:
:h :b
:h :ls
:h 'switchbuf'
:h 'hidden'
:h 'tabline'
In powerline, the list of open buffers can be displayed by adding the following line to your .vimrc configuration file:
set showtabline=2
This will add an additional status line at the top of your vim session and also highlight the active buffer.
Source: Powerline documentation
Whenever I open a split or cycle through git's history with .:Glog my cursor always ends up at the top or bottom of the page. I always hit z. to align the text and I was looking for an automatic way of doing this.
Thanks to the link from #michaelberkowski I was able to figure out the following workaround for vertical splits:
" Open vertical split with identical configuration to parent
function! AwesomeSplit()
:let savex=winsaveview()
vsplit
:call winrestview(savex)
endfunction
nnoremap <Leader>vs :call AwesomeSplit()<CR>
For navigating buffers with :.Glog I use vim-unimpared from Tim Pope. The shortcuts I use -- ]q and [q -- are just aliases for :cnext and :cprevious so I'll see if I can create a patch for vim-unimpared using winsaveview() and winrestview().
here is my problem:
i'm using taglist and nerdtree.and set quickfix window displayed no matter if it has context.
and in my vimrc, i set them toggled in a fixed order, so i can get a layout i want.
but when i use C-o, C-i, C-], it will jump to a file, and if i want the features of taglist and nerdtree i should quit it and open it again.
but it will break the layout i want. so i have to quit all and open the file again.
so, is it possible to desable some features in some specific window?
thanks for any help.:)
You can disable certain commands for buffers via :map <buffer>; for sidebar windows like from NERDTree, that's good enough, as they always display the same (scratch) buffer. For example, to disable <C-O> in NERDTree:
:autocmd FileType nerdtree nnoremap <buffer> <C-o> <Nop>
I don't fully understand your question, but another approach (as it is hard to fully control where Vim places new buffer contents) would be to extend your "build your window layout" function from your .vimrc to first clean up any existing NERDTree / TagBar windows, so that you can call it later on (e.g. via a mapping) to "fix up" your layout again.
Setup: MacVim with MiniBufExplorer plugin window spanning the entire top and Taglist plugin window on the right.
Due to the fact that I keep my Taglist on the right, whenever I open the quickfix window, it is positioned on the far right, below the Taglist window (with the same width as the Taglist window)
Is it possible to change the default opening position logic, so that the quickfix window will open below my main code window (down and to the left) or maybe span the entire width at the bottom of the Vim viewport?
While it is not possible to change the default split-window behavior
of the :copen command, one can approach the issue in two ways.
1. Use the commands that directly alter window splitting directions
(see :help :vertical and below until the “Closing a window” paragraph).
For instance, consider the commands:
:botright copen
or
:botright cwindow
to make the quickfix window open as the bottommost one, or even:
:vertical topleft cwindow
to open it to the top left of the current window.
These commands can be shortened to :bo cope, :bo cw, and :vert to cw, respectively. Also, one can, of course, create a short mapping or
a custom command for their quick invocation.
2. Alternatively, move the quickfix window to the bottom of the window
layout using an auto-command:
:autocmd FileType qf wincmd J
This trigger takes advantage of the fact that the quickfix window can
be easily distinguished by its file-type, qf. The wincmd J command
is equivalent to the
[Ctrl+W,
Shift+J]
shortcut sequence instructing Vim to move the current window to the
very bottom of the screen (see :help :wincmd and :help ^WJ).
By default, Vim opens the new window above the current one for horizontal splits, and to the left of the current one for vertical splits (:help opening-window). You can customize this behavior like most other things in Vim:
make the new window appear below the current window.
:set splitbelow
make the new window appear on the right.
:set splitright