Questions tagged [autocmd]

Vim commands you can specify to be executed automatically when reading or writing a file, when entering or leaving a buffer or window, and when exiting Vim

Vim's documentation on autocmd: http://vimdoc.sourceforge.net/htmldoc/autocmd.html

113 questions
0
votes
1 answer

Vim delete buffer only when another buffer is deleted

I've configured Vim to look like this: +------------------------------------+ | N | Code | | E | | | R | | | D | | | T | …
Loading BG
  • 131
  • 2
  • 9
0
votes
0 answers

Changing Vim Airline colorscheme on filetype

Quick possibly simple question I have set my vimrc to change the colorscheme when different filetypes are loaded; (don't ask me why but my brain sets itself to the respective language dependent on color) In order to do this I used the logical…
0
votes
1 answer

How can I Create single vim regular expression map to compile and run c++ program in windows

in linux i used something like autocmd FileType cpp nmap :w!g++ -o %:r % && ./%:r but since windows uses back slashes i thought i should try something like autocmd FileType cpp nmap :w!g++ -o %:r % &&…
alvinMemphis
  • 185
  • 2
  • 14
0
votes
0 answers

Autocmd-buflocal response to wrong buffer

I use vim open a file, and the buffer id(bufnr()) is 2, then I run a function PreviewJupyterMD in Vim commandline by call PreviewJupyterMD(). The function body is like: function! PreviewJupyterMD() " creat a md file and load file name to a…
roachsinai
  • 527
  • 5
  • 14
0
votes
1 answer

Autocmd to trigger on Window Select in Ideavim

I am trying to reproduce the tips outlined in this article in IdeaVim. Relative or hybrid line numbers work like a charm, no trouble there. However, when using with split windows in IntelliJ Idea (opened for example by ) I would like to have the…
hschne
  • 704
  • 5
  • 21
0
votes
1 answer

Is there a clean way to augment a `BufWrite` autocmd in Vim?

I've recently installed the VimWiki plug-in, and am learning about Vim's plugin architecture in general (and better using directories like after/ftplugin instead of cramming everything into my .vimrc file). I would like to call a function prior to…
Steve Hollasch
  • 2,011
  • 1
  • 20
  • 18
0
votes
2 answers

What is the correct way in Vim to autocommand ":highlight" after a buffer is loaded?

Due to various reasons, I run Vim at sixteen-colors, synced w/ my terminal's colors. In a recent Vim update, I've had to rework my "~/.vimrc" completely to get it back into running order on Linux. Initially I was shocked to find that this simple…
willsy
  • 37
  • 1
  • 7
0
votes
1 answer

Different VimResized autocmds for Shrinking and Growing

autocmd VimResized * will run the command whenever the vim application's window is resized. Is there a way to run different commands depending on whether the resize is a shrink or a grow? And, if so, are there any caveats for console…
user2141130
  • 954
  • 7
  • 22
0
votes
1 answer

Hooking Commands (runtime, source, echo, echom, echoerr) in Vim

I'm working on a vim 'logging' plugin. I'm attempting to hook any calls to 'source', 'echo', 'echom', 'echoerr'. AFAIK, the way that you typically execute arbitrary code on 'events' is through the use of an autocmd(grp) with an autocmd-event -…
nfarrar
  • 2,291
  • 4
  • 25
  • 33
0
votes
1 answer

Vim - autocmd not working for C++ file type

I'm using Windows with Vim 7.4. In my _vimrc file I have set ts=4 sw=4 sts=4 augroup Foo au! au BufRead,BufNewFile *.xml,*.css setlocal ts=2 sw=2 sts=2 au BufRead,BufNewFile *.h,*.cc setlocal ts=2 sw=2 sts=2 augroup END When I open…
Jack
  • 65
  • 3
0
votes
1 answer

Change vim-airline colorscheme via vim-sunset plugin

I just recently discovered two VIM plugins that I find very useful, namely vim-sunset (http://vimawesome.com/plugin/sunset) and vim-airline (http://vimawesome.com/plugin/vim-airline-sad-beautiful-tragic). Changing the colorscheme with vim-sunset was…
mattu
  • 944
  • 11
  • 24
0
votes
1 answer

bash script "ignores" .vimrc

I have a problem as follows: I have a script which copies a log file from remote machine, does some modification on it and then opens it in vim, problem is vim doesn't auto recognize the file type (which outside of the script id does) – I need this…
Lev
  • 105
  • 2
  • 8
0
votes
1 answer

autocmd for running Eclim's :JavaImportOrganize

I am trying to set up an autocmd for running the Eclim command :JavaImportOrganize and :syntax on each time I save a java file. au BufWritePost {*.java} silent :JavaImportOrganize :syntax on Which (expectedly) produces an error. I have tried to…
Sebastian N
  • 759
  • 7
  • 13
0
votes
1 answer

VIM autocmd corrupts default register

I'm trying to update some text lines containing filenames in specific file in Vim. To do that I've added this in my .vimrc: let logs_pat = "/ARCHIVE/logs/db_agent.log*" au! BufEnter *_search.txt execute "/\\[DBA_LOGS\\]/,$d | $put = '[DBA_LOGS]' |…
vireulgr
  • 25
  • 1
  • 7
0
votes
2 answers

How to have an autocmd not interfer with saved sessions?

I have autocmd BufEnter * silent! lcd %:p:h in my .vimrc so that the current buffer's pwd is always set correctly. Unfortunately mksession does not save sessions properly because of this. Is there either a better way to save sessions, or a way to…
Igorio
  • 918
  • 1
  • 7
  • 17