I have used Vim for 2 days now - so I'm a newbie. I'm really stuck on this problem.
When I run some commands the output is displayed twice: first in the terminal, and the in the Quickfix window (is it called that?).
For example: I type ':make'. It looks like Vim closes. Then there's some output listed. I hit 'Enter'. The output is listed again in the Quickfix window. I hit 'Enter' again.
For rails.vim I type ':Rgenerate model person name'. It looks like Vim closes. Then there's some output listed. I hit 'Enter'. And I'm back in Vim. I would like Vim to list the output in the Quickfix window, of course.
Commands like ':ls' works just fine - it lists the output fine in the Quickfix window.
I have made a video of the problem and posted it on YouTube: http://youtu.be/KvmulO4L4hc
About my setup:
I am using Mac OS X 10.7 (Lion)
I am not using MacVim
I have installed Vim using Homebrew (using https://raw.github.com/Homebrew/homebrew-dupes/master/vim.rb)
I am using Zsh (with oh-my-zsh)
I'm using pathogen.vim to install my plugins (I have only installed rails.vim and NERDTree)
My ~/.vimrc file looks like this:
" pathogen.vim
call pathogen#infect()
" Settings
set shell=/bin/sh
set expandtab shiftwidth=2 softtabstop=2 tabstop=2
set autoindent
set number numberwidth=5
set backspace=start,eol,indent
set noswapfile
" Colors
colorscheme railscasts
syntax on
" Remove all trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e
" Unmap arrow keys
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
My ~/.zshrc file looks like this:
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="highcode"
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
# COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git)
source $ZSH/oh-my-zsh.sh
# Homebrew
export PATH="/usr/local/bin:$PATH"
# rbenv
eval "$(rbenv init -)"
I hope you can help me!
Cheers! :-)
See comment from romainl above:
This is not the quickfix window: only the command line expanding to show the output of the external command. You open the quickfix window with :copen (which actually contains the output of make). In your link, it looks like he is using GVim, not CLI Vim, hence the difference in behaviour.
Related
I open Vim in "easy mode" with: vim -y
Is it possible to configure .vimrc to always open Vim in "easy mode" with just vim instead (without typing the -y)?
You can, since vim -y simply sets a number of options for that mode. It's possible to set those exact same options in the vimrc as well. They are shown in the vim documentation for evim (which is equivalent to vim -y), summarised below, see the link given for full detail:
These options are changed from their default value:
:set nocompatible insertmode hidden backup backspace=2
:set autoindent history=50 ruler incsearch mouse=a
:set hlsearch whichwrap+=<,>,[,] guioptions-=a
Key mappings changed:
<Down> <Up> Q <BS> CTRL-X <S-Del> CTRL-C <C-Insert> CTRL-V
<S-Insert> CTRL-Q CTRL-Z CTRL-Y <M-Space> CTRL-A <C-Tab> <C-F4>
Additionally:
- ":behave mswin" is used.
- syntax highlighting is enabled.
- filetype detection is enabled, filetype plugins and indenting is enabled.
- in a text file 'textwidth' is set to 78.
You can also have a look into the actual source file used for this mode if you do the following within a vim session:
:e $VIMRUNTIME/evim.vim
This shows the actual code run when starting with vim -y.
But I suspect an easier way to do it, at least with a UNIX-style OS, would be to just set up an alias, something like the following in your start-up scripts:
alias vim='/usr/bin/vim -y`
This would allow command-line invocations to start with easy mode. It won't help non-command-line invocations but you could do that (in UNIXes and Windows) by providing a script earlier in the path to do so.
For example, you could create a bash script of the form:
/usr/bin/vim -y "$#"
and call it vim, ensuring that where you put it comes in the path before /usr/bin.
My centos 7 has two vim binaries:
/usr/bin/vi
/usr/bin/vim
When launching either of them they bring up:
VIM - Vi IMproved
version 7.4.1099
From searching around online I believe that these two versions are vim and vim-minimal. The problem is that vi and vim-minimal interpert the ~/.vimrc differently. When opening vim its great. When opening vim-minimal I get lots of errors. Below is a representation of my ~/.vimrc file:
set number
set nowrap
set modeline
set clipboard=unnamedplus "Enables mouse center clip pasting, while holding shift, in insert mode.
"Below sets up the mouse in such a way that allows vi split screen resizing while in tmux and screen.
set mouse+=a
if &term =~ '^screen'
" tmux knows the extended mouse mode
set ttymouse=xterm2
endif
""""""""""""""""""""""""""""""""""""""""""""""""
""" User Defined Functions
""""""""""""""""""""""""""""""""""""""""""""""""
"Opens up sage specific work in new tabs
fu! Setup1()
:bd!|e /home/me/example1.h | vsplit /home/me/example1.cc
:tabnew /home/me/example2.h | vsplit /home/me/example2.cc
:tabnew /home/me/example3.h | vsplit /home/me/example3.cc
:tabnew /home/me/example4.h | vsplit /home/me/example4.cc
:tabnew /home/me/example5.h | vsplit /home/me/example5.cc
:tabnew /home/me/example6.h | vsplit /home/me/example6.cc
endfunction
"Opens up the most edited rc files in new tabs
fu! RCS()
:bd!|e ~/.cshrc
:tabnew ~/.vimrc
:tabnew ~/.tmux.conf
endfunction
The problem is my user defined functions. When /usr/bin/vi is opened it opens all of the documents in my two functions in new tabs. A resonable workaround would be to not use /usr/bin/vi but it is what git opens.
Ideally I would be able to have an if statement that checks what binary is running this rc file. Is that possible?
You can configure git to use the editor of your choice. You can set the environment variable GIT_EDITOR or you can set a configuration file with git config --global core.editor /usr/bin/vim to set the core.editor variable.
If neither of those is set, it may fall back to the VISUAL environment variable. On that note, you will likely want to set that in your ~/.bashrc as a more system-wide solution so other utilities that may want to open an editor default to /usr/bin/vim over /usr/bin/vi
The following blog post discusses how to degrade vimrc for different builds of vim that may have different packages and different capabilities (and thus react to vimrc differently):
gracefully degrading .vimrc
(answer provided by max630 in the comments to my question)
I have a $HOME/.vimrc file which I have configured for many options like below but not limited to.
set foldmethod=indent
set foldnestmax=10
set mouse=a
set number
These all work fine if I open a file with vim however if I open with vi or view the file none of the config work, which is fine but I get errors for some.
line 104:
E538: No mouse support: mouse=a
line 205:
E518: Unknown option: foldmethod=indent
Press ENTER or type command to continue
After searching quite a while I was able to remove some of these.
if has('mouse')
set mouse=a
endif
silent! set foldmethod=indent
However this is just suppressing them. And the linenumbers are still being displayed with vi or view which look pretty bad and many people login to the box will be suddenly mystified by the yellow line numbers.
How to make vi not take up these config.
I powerbroker to the linux box. Can I make .vimrc setting just for me.
vi and vim are the same executable.
I'd suggest you change the name of your vimrc:
$ mv ~/.vimrc ~/.myvimrc
and start Vim with:
$ vim -Nu ~/.myvimrc
You could add an alias to ~/.bashrc (or whatever works in that system) to ease your workflow:
alias myvim='/usr/bin/vim -Nu ~/.myvimrc'
As vi does not support all options of vim, What I do is to set alias for vi to vim in my rc file
alias vim='vim -p'
alias vi='vim -p'
The -p is not really required. but I kinda like tabbing enabled by default on vim. So every time, if you hit vi or vim, it behaves the same.
You can make this permanent, if you like, by adding the lines to ~/.bashrc, assuming you are using bash. You need to source ~/.bashrc to take immediate effect without logging off.
I have installed cvim and NodeTree plugins and generated an exuberant ctags file for my build tree.
This is what my ~/.vim/.vimrc file looks like:
:noremap :TlistToggle
:let Tlist_Show_One_File = 1
:let Tlist_Exit_OnlyWindow = 1
:let Tlist_Use_Right_Window = 1
set tags=./tags;/
set number
set tabstop=4
set incsearch
When I start editing a file, I notice that Ctrl ] does not work and I have to resort to typing ta: funcname - which gets tiring after a while. Interestingly enough, Ctrl T pops me off the tag stack as expected - I don't understand whats going on - how do I fix this?
Incidentally, vim (appears to) completely ignores the contents of my .vimrc file and I always have to type the same commands in the editor, so as to get the settings I want - very annoying.
Last but not the least, I used to be able to type :make in the editor window, drop to the console and then have the build results displayed in a little window which I can then go to and select a line (with an error or warning say), and then have the editor automagically take me to the offending line - unfortunately, I don't remember the plugin (or commands) I used to allow me to build from within vim.
So, how do I:
Fix my vim setup so that I can move to definitions/declarations using Ctrl-]
Fix my .vimrc file so that contents are actually applied to my vim session.
Find the appropriate plugin to install to allow builds (using make) from within vim
You're asking about a weird mix of problems.
Fix my vim setup so that I can move to definitions/declarations using Ctrl-]
The tags functionality is working; I suspect that you have a mapping blocking Ctrl-]. Try
:verbose nmap <C-]>
and
:nunmap <C-]>
Fix my .vimrc file so that contents are actually applied to my vim session.
:echo $MYVIMRC
will tell you the location of the .vimrc that Vim uses. Also, check the output of :scriptnames which scripts get loaded, and read :help vimrc to understand the logic Vim applies.
Find the appropriate plugin to install to allow builds (using make) from within vim
That's built into Vim. With the appropriate 'makeprg' set (it defaults to make), you can run :make. Vim parses the output (through the 'errorformat' option), and you can open the quickfix list via :copen.
Your vimrc is:
~/.vim/.vimrc
If you run Vim 7.4, it should be:
~/.vim/vimrc
or
~/.vimrc
If you run Vim 7.3 or older, it should be:
~/.vimrc
And... what Ingo said.
The latest upgrade of Ubuntu made my vim colorscheme unusable. I know how to set it manually (:colo evening, for example), but I want to set the default for all vim sessions. I see reference in other places to .vimrc, but the right location and syntax have eluded me thus far.
Put a colorscheme directive in your .vimrc file, for example:
colorscheme morning
See here: http://vim.wikia.com/wiki/Change_the_color_scheme
Your .vimrc file goes in your $HOME directory. In *nix, cd ~; vim .vimrc. The commands in the .vimrc are the same as you type in ex-mode in vim, only without the leading colon, so colo evening would suffice. Comments in the .vimrc are indicated with a leading double-quote.
To see an example vimrc, open $VIMRUNTIME/vimrc_example.vim from within vim
:e $VIMRUNTIME/vimrc_example.vim
It's as simple as adding a line to your ~/.vimrc:
colorscheme color_scheme_name
You can try too to put this into your ~/.vimrc file:
colorscheme Solarized
What was asked for was to set:
the 'default', not some other color profile, and
'for all vim sessions', not simply for the current user.
The default colorscheme, "for all vim sessions", is not set simply by adding a line to your ~/.vimrc, as all of the other answers here say, nor is the default set without the word 'default' being there.
So all of the other answers here, so far, get both of these wrong. (lol, how did that happen?)
The correct answer is:
Add a line to your system vim setup file in /etc/vim/ that says
colorscheme default
or using the abbreviation
colo default
but not capitalized as
colo Default
(I suggest using the full, un-abbreviated term 'colorscheme', so that when you look at this years later you'll be able to more easily figure out what that darn thing does. I would also put a comment above it like "Use default colors for vim".)
To append that correctly, first look at your /etc/vim/vimrc file.
At the bottom of mine, I see these lines which include /etc/vim/vimrc.local:
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
So you can append this line to either of these two files.
I think the best solution is to append your line to /etc/vim/vimrc.local like this:
colorscheme default
You can easily do that in bash with this line:
$ echo -e "\"Use default colors for vim:\ncolorscheme default" \
| sudo tee -a /etc/vim/vimrc.local
#
# NOTE: This doesn't work:
#
# $ sudo echo 'colorscheme default' >> /etc/vim/vimrc.local
#
# It's the same general idea, and simpler, but because sudo doesn't
# know how to handle pipes, it fails with a `Permission denied` error.
Also check that you have permission to globally read this file:
sudo chmod 644 /etc/vim/vimrc.local
With $ tail /etc/vim/vimrc.local you should now see these lines:
"Use default colors for vim:
colorscheme default
You can just use the one-liner
echo colorscheme koehler >> ~/.vimrc
and replace koehler with any other available colorscheme. Imho, all of them are better than default.
Once you’ve decided to change vim color scheme that you like, you’ll need to configure vim configuration file ~/.vimrc.
For e.g. to use the elflord color scheme just add these lines to your ~/.vimrc file:
colo elflord
For other names of color schemes you can look in /usr/share/vim/vimNN/colors
where NN - version of VIM.
Ubuntu 17.10 default doesn't have the ~/.vimrc file, we need create it and put the setting colorscheme color_scheme_name in it.
By the way, colorscheme desert is good scheme to choose.
Copy downloaded color schemes to ~/.vim/colors/Your_Color_Scheme.
Then write
colo Your_Color_Scheme
or
colorscheme Your_Color_Scheme
into your ~/.vimrc.
See this link for holokai
OS: Redhat enterprise edition
colo schema_name works fine if you are facing problems with colorscheme.