I would like to close NerdTree on vim startup using shell arguments. Something like this:
vim +NERDTreeClose file.txt
or
vim -c "NERDTreeClose" file.txt
should do the trick, but it doesn't. Automatic start of NERDTree is defined inside .vimrc (by autocmd vimenter * NERDTree) and it should stay there.
The point of all this is to configure vim as a mergetool so I don't need NERDTree opening on startup.
Related
There's some clunky behavior I'd like to resolve:
In vim I can use :terminal to bring up a shell window. But if I type something into it, I can't edit it like a normal shell: I'm stuck either in a useless normal mode, or I'm in an insert mode where I can only write new letters or delete them at the end of the line. I can't move the cursor to the middle and change, say,
cd ~/Picturs/MyLovelyHusbandAndChildren2017/VacationPhotos/Aruba
into
cd ~/Pictures/MyLovelyHusbandAndChildren2017/VacationPhotos/Aruba
without simply deleting everything from ~/Pictur to the end and rewriting it. Is there any way at all around this or is it a basic limitation of how vim works? This is frustrating to me because I'd like to use ghci in the shell window but this makes it much less responsive.
There are some specific configs you can do both on vim or neovim to tacle this issue, in my case, neovim, I have these lines on my init file:
augroup neovim_terminal
autocmd!
" Enter Terminal-mode (insert) automatically
autocmd TermOpen * startinsert
" Disables number lines on terminal buffers
autocmd TermOpen * :set nonumber norelativenumber
" allows you to use Ctrl-c on terminal window
autocmd TermOpen * nnoremap <buffer> <C-c> i<C-c>
augroup END
Note the autocmd TermOpen * startinsert, that line makes sure, as soon as I enter a new terminal on neovim it will be in inert mode.
I would like to use the mouse features of gvim, but have it behave as normal vim otherwise. For that, I have added the line set guioptions= in my .gvimrc .
I could make an alias to gvim (mapping it to exec gvim), so that when I open gvim from a terminal, it appears to open in the same window.
Is there any way to go back to the starting terminal when I close gvim? (like when you close vim)
:set mouse=a in vim did the trick.
I have this vim plugin
http://www.vim.org/scripts/script.php?script_id=4111
installed. I have included the following lines for the .vimrc:
autocmd BufRead,BufNewFile *.log set syntax=log4j
I am getting "autocmd unknown command"
when I am running
. .vimrc
from the bash
Please help.
The . command in Bash reads the argument as a Bash script; you're executing the Vim configuration as a Bash script. Of course, Bash doesn't know the autocmd command, and therefore complains.
Vim will automatically read in your ~/.vimrc on startup (cp. :help initialization). Just open a new Vim instance, and your new configuration will apply. You can ensure that the .vimrc has been read via :scriptnames (the file path should be listed at the start), or list your defined autocmd via :autocmd BufRead *.log
If you :edit somefile.log, you can verify that the syntax has been set via :setlocal syntax?
You don't need to run that command, once you will open any "*.log" file using "vim" the plugin will be used. if installed correctly.
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 for coloring the log.
Script as follows:
/usr/bin/rcp 14.1.61.10$node:/output/LocalLog_IPNode$node.log /export/home/fpd/tmp/tmp_local_log
chmod 777 /export/home/fpd/tmp/tmp_local_log/*
sed -i 's/[A-Z]\{4,8\}.*[oigus][kbdct][sel]\//---/g' /export/home/fpd/tmp/tmp_local_log/LocalLog_IPNode$node.log
vi /export/home/fpd/tmp/tmp_local_log/LocalLog_IPNode$node.log
My .vimrc:
au BufNewFile,BufReadPost LocalLog* set filetype=local_log
Note that the files opens in vim (if it helps the manual command ":set syntax=local_log" doesn't work either).
After exiting the script and manually opening the log everything works fine =(
Your problem is that the autocommand option is only availaible in vim and not vi.
So if this is available on your system, you should replace the last command line by :
vim /export/home/fpd/tmp/tmp_local_log/LocalLog_IPNode$node.log
Vim stands for "Vi Improved" and many options are only available in the latter.
To be sure you can do:
:help autocommand
It is always mentioned if the feature is vi or vim compatible.
I was fascinated when I discovered vi-like bash's editing mode. One can easily toggle it by issuing set -o vi command. But is there any way to toggle vim-like mode?
I mean when you are in a vi-like mode you can press v key and edit your commands in a fully functional vi editor's window but I would like to know how to force bash to start vim editor instead of vi because of the perks vim provides us (visual selection, additional commands etc)?
If you set EDITOR variable, in bash you can press Ctrl-x ctrl-e to edit your current command line in your EDITOR e.g. vim
EDIT
the ctrl-x ctrl-e is for emacs mode commandline editing, which is the default one. If you have already set it to vi mode, you could do what you have said, pressing the v. If you want to open the cmd line in vim, you have to set the EDITOR variable (in your .bashrc for example)
Personally I edit command line in emacs mode, even though vim is my main (and only) editor.
In your .bashrc, put the following line:
export VISUAL=/usr/bin/vim
If you want vim in many other contexts too, such as in git, you should also set EDITOR:
export EDITOR=/usr/bin/vim