I have a .vimrc script that automatically creates a buffer for a bash terminal with Conque (and goes to insert mode) and then returns to the previous buffer (the file I have opened).
autocmd VimEnter * ConqueTermSplit bash
autocmd VimEnter * wincmd p
The problem is that when I start vim I am left in insert mode and I have to press <Esc> every time to go to normal mode.
Writing <C-v><Esc> at the end of .vimrc doesn't work, as the command is executed in command mode.
I don't have that plugin
autocmd VimEnter * exec "ConqueTermSplit bash" | silent norm!
could work
Update Just found out that Conque's documentation rocks
You can use the conque_term#open({command}, [buf_opts], [remain]) function to achieve what you want:
If you don't want the new terminal buffer to become the new active buffer, set
[remain] to 1. Only works if you create a split screen using [options].
So what you'd want is roughly
autocmd VimEnter * call conque_term#open('/bin/bash', ['split', 'resize 20'], 1)
Related
I would like to create a vim command that is waiting for an input THEN that will execute ':cw' automatically after the first command.
Here is what I try:
noremap <C-p> :exec ":ProjectGrep /".input('Search: ')"/ src/**"<CR>:cw
But the ':cw' does not execute after the command, it complete the input().
Add the following snippet to your vimrc to make Vim open the quickfix/location window when there are valid errors/locations:
augroup qf
autocmd!
autocmd QuickFixCmdPost [^l]* cwindow
autocmd QuickFixCmdPost l* lwindow
augroup END
That snippet addresses what I believe is your underlying issue (having the quickfix window open automatically after your search command), though, not your actual question.
Anyway, cwindow should be the last command in the function called by your :ProjectGrep command; not at the mapping level.
I've want to make relativenumber disabled in the command-line mode. Because somethings I need know the absolute linenumbers in the command-line mode (goto someline by :<line_number>)
my setting as below, but it won't work...
autocmd CmdwinEnter * set norelativenumber
autocmd CmdwinLeave * set relativenumber
Somehow, this setting (Get fome here) work fine:
autocmd CmdwinEnter * let b:ei_save = &eventignore | set eventignore=CursorHold,InsertEnter
autocmd CmdwinLeave * let &eventignore = b:ei_save
I want to know why my CmdwinEnter/CmdwinLeave for **relavitenumber` didn't work, and how can I make it.
By the way,
This method works fine in Insert mode by:
autocmd InsertEnter * set norelativenumber
autocmd InsertLeave * set relativenumber
And:
My Vim version is: 7.4.250
Here is my whole vimrc.
This situation happens in my both Win7 and Linux system.
Yes, I read this thread, and the "best answer" doesn't works either.
you got confused by the event name: CmdwinEnter/Leave, they would be triggered by enter/leaving command line window, not command line mode. :h cmdwin
I guess with your current setting, in command mode, if you press ctrl-f (entering cmd-win), you should see the line number change, and it would be applied on the command line window, you have to find the window id of your main editing, to change the setting.
To catch the "event" to entering command line mode, you could map normal mode : to a function, there, you could do preprocessing.
For catching the "event" of leaving cmd mode, you have to check the current mode all the time, if it is changed into normal.
I'm using vim 7.3 and Rainbow Parentheses plugin. When opening multiple tabs with vim -p file1 file2 or with vim -S session.vim, or even with tabnew file or any other method, my parenthesis are colored in only one file.
I just put this into my .vimrc : au VimEnter * RainbowParenthesesToggle
as said here. I tried to use :RainbowParenthesesToggle on the other tabs once opened but it only toggles in the parenthesis-activated tab.
What should I do to make things work in all tabs ?
I made it work by adding the same instructions as here in my .vimrc, thanks to FDinoff. I replaced the last instruction to make it work using tab, as I intended first.
function! Config_Rainbow()
call rainbow_parentheses#load(0)
call rainbow_parentheses#load(1)
call rainbow_parentheses#load(2)
endfunction
function! Load_Rainbow()
call rainbow_parentheses#activate()
endfunction
augroup TastetheRainbow
autocmd!
autocmd Syntax * call Config_Rainbow()
autocmd VimEnter,BufRead,BufWinEnter,BufNewFile * call Load_Rainbow()
augroup END
The VimEnter flag on the autocommand tells vim to perform the command specified (in this case RainbowParenthesesToggle only when starting the editor, which is in your case when you open the first file.
If you want to extend the functionality to everytime you load a buffer you should do something like:
autocmd BufRead,BufNewFile * RainbowParenthesesToggle
I currently have the following in my .vimrc:
au VimEnter * NERDTree
au BufWinEnter * NERDTreeMirror
This I believe launches NERDTree when I open Vim, as well as when I open a new tab using a plugin. Currently, when I launch Vim using
vim
at the command line, the cursor is sitting in NERDTree ready for me to navigate my files, which is great. However, when I use
vim my-file.txt
the cursor remains in the NERDTree window. I'm aware that I can add this to my .vimrc:
au BufNew * wincmd l
But that means the cursor will always be placed in the window to the right of NERDTree, even if I don't specify a file.
Does anyone have any ideas?
You can make the command conditional on whether arguments were passed to Vim:
:au VimEnter * if argc() > 0 | wincmd l | endif
(I'd use the VimEnter event for that; just make sure this autocmd comes after the one that opens NERDTree.)
PS: There are a couple of related questions here:
Auto-open NERDTree in "EVERY" tab
How do you add NERDTree to your vimrc?
I've setup my vim editor (I use MacVim) to save files automatically when the focus is lost:
autocmd FocusLost * silent! wall
I also automatically strip trailing whitespace from python files using this auto command:
autocmd BufWritePre *.py :%s/\s\+$//e
This auto command works perfectly when I save the file manually (either by typing :w or by pressing ⌘s) but it is not executed (i.e. the whitespace is not stripped) when I switch to another application and the buffer is automatically written.
How can I modify these auto commands to make them work together?
You need to change your FocusLost autocommand to:
autocmd FocusLost * nested silent! wall
See :h autocmd-nested for details.
I can't test this in a graphic Vim, but you can try some options:
Join some events in the same autocommand autocmd BufWritePre,FocusLost *.py ...
Execute an autocommand from an event, something like:
autocmd BufWritePre *.py :execute "%s/\s\+$//e" | doautocmd FocusLost %