Whenever I work with multiple buffers, there is always one empty. I would like to not have that if I open a file with vim from the command line (i.e. I don't want to create a new file, or choose to create a new file by naming it first and starting vim with that name). How can I do this?
Edit:
I'm launching gvim the following way:
I have an alias in my bashrc: alias g="gvim --remote-silent"
I open files from the command line with: g name-of-file
At this point (if I didn't already have an instance of gvim open), I have two buffers:
Edit2:
Platform is Linux Mint, version is: VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 24 2011 07:07:39).
I updated my NERDTree plugin as David suggested, but it didn't help. Other plugins I use: Pathogen, a, doxygentoolkit, nerdtree, snipmate, vim-rails,
ack_plugin, easymotion, protobuf, sparkup, yankring,
bufexplorer, matchit, rainbow, surround,
clang_complete, nerdcommenter, repeat
I don't have your problem on
linux, gvim - Vi IMproved 7.3 (2010 Aug 15, compiled Mar 24 2011 07:07:34) Included patches: 1-35
windows gvim - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 9 2008 18:46:22) MS-Windows 32-bit GUI version with OLE support
You are probably looking at a bug.
You might be able to debug things by cleaning your $MYVIMRC (temporarily) and running gvim --noplugin.
Alternatively inspect all settings (like bufhidden and other suspect parties)
:set
:setglobal
and see from which script/plugin they are being set (bufhidden as an example only here):
:verbose set bufhidden
:verbose setglobal bufhidden
You might also inspect autocommands (that might prevent buffers from being wiped)
:verbose au
To avoid this I changed my alias:
g() { [ -z "$(command gvim --serverlist)" ] && command gvim "$#" || command gvim --remote-silent "$#" ; }
If the list of server is empty: launch plain gvim, otherwise launch with remote-silent option.
Related
I am having neovim and vim in my machine sharing same vimrc file.
When i press home and end key it works inside vim but not in neovim.
Neovim is installed using AppImage.
Vim version is : VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 9 2019 03:17:15)
NeovIm version is : NVIM v0.4.4
Build type: RelWithDebInfo
LuaJIT 2.0.5
OS :Centos 7
I tried set term=xterm and set term=xterm-256color but it fails
E518: Unknown option: term=xterm-256color
echo $TERM returns xterm
How to enable home and end button in nvim?
Update:
There is a help document , :help $TERM
When i changed the term export TERM=putty-256color ,it works.
But i have to keep setting it many times . Need a way to set it in vimrc.
I use tmux and had TERM set to xterm-256color. It was fixed after setting it to screen-256color.
Source: https://github.com/neovim/neovim/issues/6134
Add this to your tmux config:
bind-key -n Home send Escape "OH"
bind-key -n End send Escape "OF"
source: https://github.com/neovim/neovim/issues/6134#issuecomment-758475291
In vim, when I am in insert mode and press the arrow keys I get letters instead:
As you can see, the arrow keys, when pressed, insert a line above the current cursor position including either A, B, C or D.
How do I stop this?
Things I've tried
I have set nocompatible in my ~/.vimrc (vimrc pastebin), I am using pathogen and here is my ~/.vim/bundle directory:
YouCompleteMe/
emmet-vim/
nerdtree/
node/
vim-airline/
vim-markdown/
The problem only started recently, but I can't think of what caused it.
I've done :set term=builtin_ansi, and this fixes the problem but removes all my colors.
$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 29 2016 12:51:13)
MacOS X (unix) version
Included patches: 1-2290
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
...
See http://pastebin.com/5z1HbpqW for the whole output.
$ echo $TERM
xterm-256color
and in vim:
:set compatible?
nocompatible
:set term?
term=xterm-256color
Use this:
:set term=builtin_ansi
Source: http://vim.wikia.com/wiki/Fix_broken_arrow_key_navigation_in_insert_mode
Here is my .vimrc
1 syntax on
2 set ts=4
3 set number
4 set smartindent
5 set shiftwidth=4
However, I tried to edit HelloWorld.java and HelloWorld.c. Both have pure regular black font. No any highlighting!
I also tried :syntax on after the vim is open, but no luck.
\>vim -version
VIM - Vi IMproved 7.3 (2010 Aug 15)
\>cat /etc/*-release
openSUSE 11.4 (x86_64)
VERSION = 11.4
CODENAME = Celadon
When you edit the file, are you using
vim filename
This can matter. In some server configurations, if you do vi filename you get vim, but it's a very stripped down version of vim that is very much like the original vi (which does not, among other things, do syntax coloring). On a system configured in this way, if you instead type vim filename, you get the full featured vim.
I just worked through this with a person who was on a server that had the vim-minimal package installed as well as another vim package. I suspect (but did not verify that) the vim-minimal package installed its executable as /bin/vi.
The difference was very clear when you looked at the actual files (i.e. ls -l /bin/vi vs ls -l /usr/bin/vim)--one was about ten times the size. Both of them were actually vim, same version number and everything, but the /bin/vi one was compiled with very few features enabled.
To make it even more confusing:
vi existing.pl
opened the .pl file, gave no syntax coloring
vi [enter]
gave the vim splash screen, and from there
:e existing.pl
opened the file with syntax coloring on.
A comment from Jan Wilamowski suggests checking by doing:
vi --version
If that shows that the syntax feature was not compiled in, try
vim --version
and see if it is compiled in there.
You'll need to install the vim-data package on openSUSE for vim syntax colouring to work.
Sounds strange, I know that this is not pulled in by default with the vim package but AFAIK it's for people who want to create tiny base installs.
Package vim-data contains the runtime files.
Also make sure your remote environment has an appropriate TERM variable set TERM=screen-256color, TERM=xterm, TERM=xterm-256color should all work just fine with ssh and ssh with screen/tmux.
If all above have been done and you see some underlines and bold instead of actual colors... this might work for you:
export TERM=xterm-color
in your .vimrc, I don't see filetype setting. you could try to add:
filetype plugin indent on
to your vimrc.
if you don't have set nocp, add this line too.
if you read :h filetype
:filetype on
Each time a new or existing file is edited, Vim will try to recognize the type
of the file and set the 'filetype' option. This will trigger the FileType
event, which can be used to set the syntax highlighting, set options, etc.
For some strange reason on MacOS, 'syntax on' must be the first line in your .vimrc file. The line appears to be ignored if placed elsewhere in the file.
One item not mentioned is :set syntax=<type>, e.g. :set syntax=markdown.
This has been successful in instances where other techniques above were not.
Currently running:
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Sep 1 2012 18:08:47)
MacOS X (unix) version
Included patches: 1-646
Compiled by Bjorn Winckler <bjorn.winckler#gmail.com>
I have these lines in my .vimrc
if has("gui_macvim")
source ~/.vim/vimrc/mygfuncs.vim
endif
In the mygfuncs file are some functions that set the guitablabel and guitabtooltip based on two custom functions. The file is being sourced (because the functions are defined), but the lines that set those variables using those functions aren't working:
set guitabtooltip=%{GuiTabToolTip()}
set guitablabel=%{GuiTabLabel()}
At this point, the variables are set properly, because if I
:set guitabtooltip
Vim responds with
guitabtooltip=%{GuiTabToolTip()}
But it isn't actually being applied.
But if I then :so ~/.vimrc, the tab label and tooltips are applied.
What is going on here?
I believe the only time it will be properly executed is when you have the code block:
if has("gui_macvim")
source ~/.vim/vimrc/mygfuncs.vim
endif
... in a self contained ~/.gvimrc file.
They are cluttering up my working dir. Maybe it could just put them in the vim directory or something?
You can disable it with
set noswap
in your _vimrc. As a matter of fact, that is the prefered behaviour when working with really large files. See more under :help swapfile
For settings them aside in a predefined directory, tis would be best to read a bit of this
You can change the directory for swap files in .vimrc with
set directory=/tmp
See directory for more information.
As mentioned,
set noswap # in vimrc
:bufdo set noswap # when running
Or upon launch:
vim -n
Using:
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012 04:25:35)
...
:help swapfile shows the command as: noswapfile