While coding Python, I like Vim's omnicompletion function, but I don't want Scratch Window to pop up at top.
How can I disable it?
(I'm using gVim 7.3)
This behavior is defined by the presence of preview in the value of the 'completeopt' option.
The default value is:
menu,preview
To remove preview, simply add this line to your ~/.vimrc or modify an existing completeopt line:
set completeopt-=preview
If you don't mind the preview window too much, but want to easily close it, you can use the :pclose command or CTRL-W z keyboard combination see :help :pclose.
Related
The cursor blinking is off by default in Neovim and I want it back. I have tried to apply different arguments to guicursor, but didn't succeed. Since I want it to blink the same way in every mode, I think, I need something with the letter 'a' in it.
Here's what I have tried so far:
:set guicursor=a:blinkwait700-blinkon400-blinkoff250 (I also tried with 'i')
:set guicursor=a:blinkon100 (as the opposite of a:blinkon0 which switches it off)
I've already looked into the help but it didn't help me unfortunately.
Update:
What is peculiar is that :set guicursor=a:blinkon100 enables the blinking in gVim, but not in Neovim.
From neovim 0.2 onwards, setting guicursor does achieve the desired effect:
" Enable blinking together with different cursor shapes for insert/command mode, and cursor highlighting:
set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
\,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor
\,sm:block-blinkwait175-blinkoff150-blinkon175
Find more by typing :help 'guicursor' from inside nvim.
For more info, see the official wiki
Finally, if you use st, you can patch it to get this working:
https://st.suckless.org/patches/blinking_cursor/
EDIT: I noticed from the comments of the first answer that OP was talking about nvim-qt, for those interested in that, a fix for it has been merged at the beginning of this year.
If you are using the st terminal by Suckless then that does not support cursor blinking I belive, otherwise if your terminal does support it try setting the option let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 in your init.vim file. You could also pass that on the command line such as NVIM_TUI_ENABLE_CURSOR_SHAPE=1 nvim.
Im using vim with ctag+tagbar plugin to navigate through kernel code and its amazing ! Thanks to a guide I saw here.
I read here about some nice shortcuts for ctags that helps a lot, but I couldnt find a way that a definition(of structs/function etc) would show in popup box - something like eclipse ide.
Is there a way to do so with ctag? is there a plug-in I can add to vim that would that ? so when the mouse cursor(or also keyboard cursor) on function a popup box next to it will show?
Thanks!
Generally, you should avoid trying to use Vim as an IDE. It's meant to be a modular text editor.
Having said that, if you are looking for eclipse functionality inside of Vim, you may want to consider eclim. Another good set of plugins are the Clang based tools, like clang-format and YouCompleteMe.
ctags is very useful plugin, but if you also use ctags you can then copy file http://cscope.sourceforge.net/cscope_maps.vim to your ~/.vim/plugin directory and this will add keymappings that will allow you to jump to definition or show it in horizontal or vertical split.
I also added to my cscope_maps file an extra set of mappings like so:
nmap <C-h>g :tab cs find g <C-R>=expand("<cword>")<CR><CR>
to open my search in a new tab.
Example above allows you to use Ctrl+h and then g to "find global definition(s) of the token under cursor" and open it in a new tab.
Consider using cscope- it can also work with ctags (I always use both).
I know that this is not a pop-up window, but vim is not an IDE.
Is there an autocmd for when the preview window is opened/closed?
I want to scroll the main window n lines up when it the preview window is opened, then n lines down when it is closed, to counteract the "moving text" effect that occurs natively.
Am I able to do this with the relevant autocmd (and what is it), or is there a better way for me to achieve this?
There is no such autocmd event. But you can use WinEnter and BufDelete associated with previewwindow option to achieve something similar.
Using WinEnter you can check previewwindow; if you are on preview window, you can set a buffer variable to differ this event from subsequent events that can be generated by moving to another window and back to preview window. You can also set au BufDelete <buffer> call MyRestoreMainWindow() to call your function when preview window is closed.
I see this question asked often and always scratch my head wondering what is that window-shifting people talk about that I don't experience.
Well, today it occurred to me that two options that I've added to my ~/.vimrc a long time ago have the pleasant side effect of preventing that dreaded window-shifting:
set splitbelow
set splitright
Give it a try!
I was actually wondering the same thing except with the tab bar -- how to prevent that annoying shift from occuring when the tab bar is shown or hidden. Have you considered a wrapper function? The following seems to work for the ps example (it will still cause a shift if the preview window would obscure the cursor)
se splitbelow splitright
fun! PsWrapper(text)
let view=winsaveview()
exe 'ps' a:text
call winrestview(view)
endfun
While we're here ... the tab bar case seems to require some black magic. Ie, as someone pointed out, the tabbar will cause the text to scroll down if the cursor is above the middle line (??). But this seems to work - to always show a tab bar:
let [view,g:stal]=[winsaveview(),&stal]
let [view.topline,&stal]=[view.topline+!g:stal,2]
call winrestview(view)
and to restore the original tabbar setting
let [view.topline,&stal]=[view.topline-!g:stal,g:stal]
call winrestview(view)
You can't really do this with a simple autocmd - Using the WinEnter/WinLeave/BufEnter/BufLeave auto commands all have minor quirks (stated in the vim documentation) so they won't consistently solve your problem completely.
If this happens to you when opening splits, then you can solve this like #romainl suggested, by defining in your .vimrc :
set splitright
set splitbelow
BUT... This will still happen when opening various 'preview' windows, or using the quickfix or location list windows vim has to offer. I use them a lot, and this problem really annoyed me, so I wrote a plugin to solve this.
You can check it out here: https://github.com/gillyb/stable-windows
It works by maintaining state of the cursor position and top line number of the windows open in your vim layout, and restoring them each time you switch to a different buffer.
It's relatively new (as of writing this answer) so if you find any bugs feel free to open an issue, and I will try to address them quickly.
Hope this helps! :)
I love the sorts of features that applications like textedit and sublime edit have, where you can see the current namespace in a little bar in the UI. Is there any way to make vim do that?
The Powerline plugin shows the current function.
Would TagBar or TagList help? Both provide a small function to add to your statusline to that effect. Or maybe this other plugin?
I'm not fan of that kind of feature. I prefer to use <C-w>} when I need.
here's a one-liner you can put in your .vimrc (need to have taglist.vim installed though):
set statusline=%<%f\ [%{Tlist_Get_Tagname_By_Line()}]\ %h%m%r%=%-14.(%l,%c%V%)\ %P
...that'll show the current function your cursor is in as you move around.
I forget the specifics but sometimes you'll want to manually refresh it, in which case this mapping is useful:
map <F4> :TlistUpdate<CR>:TlistHighlightTag<CR>
^ that'll refresh the function name in your statusline when you press F4
So, the :Vexplore command in vim opens a nice little directory browser to the left.
But how do I then open a file from that side-pane into the main window on the right?
One would assume there's a simple mapping for it, but I can't seem to find it.
I think you want o or P
Also, have a look at the documentation, e.g.
:he netrw-p11
It turns out it's just a single line in .vimrc:
let g:netrw_browse_split=4 " Open file in previous buffer
Source: http://vimcasts.org/episodes/the-file-explorer/#comment-45366660
I'm sure what you're looking for is this:
:Vexplore!
This is the same command you would use to navigate to different windows in Vim (like quickfix window, or different split), everything is explained in
:help windows.txt
But to answer to your question directly:
CTRLwCTRLh to move to the left window
CTRLwCTRLl to move to the right window
then Enter to select the file you want to open.
You might want to read :help netrw as well
The latest netrw plugin (up to v153f) now provides the :Lexplore command, which opens an explorer on the right hand side of the vim display. It sets g:netrw_chgwin so edits occur in the window to the right of the netrw window. You can get it from http://www.drchip.org/astronaut/vim/index.html#NETRW .