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.
Related
I have used vim for a while now, but after my friend introduced me to gvim, I'm trying to use it now. I have basic vimrc settings of :
set guifont=Monaco:h17
colorscheme zellner
set number
syntax on
I noticed that the settings were applied to my gvim. I want a different colorscheme for gvim and vim as I usually open the files I'll read quickly with vim or vi, and use gvim as my main code editor.
I heard people talk about the .gvimrc file, but I don't have it where my .bashrc, .zshrc, and .vimrc are.
How do I have separate colorschemes for gvim and vim?
Vim doesn't create either ~/.vimrc or ~/.gvimrc for you so you have to create them on your own.
You can either create the missing file in your shell, then edit in Vim:
$ touch ~/.gvimrc
$ vim ~/.gvimrc
<some editing>
:wq
or do everything from Vim:
:e ~/.gvimrc
<some editing>
:wq
Note: ~/.vimrc is still sourced whether you have a ~/.gvimrc or not so your gvimrc can be kept lightweight by only having GUI-specific options and overrides. In your case:
" ~/.vimrc
colorscheme zellner
set number
syntax on
" ~/.gvimrc
set guifont=Monaco:h17
colorscheme slate
You can do it in a single ~/.vimrc:
if has("gui_running")
colorscheme zellner
else
colorscheme blue
endif
See http://vimdoc.sourceforge.net/htmldoc/eval.html#has() and http://vimdoc.sourceforge.net/htmldoc/eval.html#feature-list
Following the instructions here I have an ftdetect file, ~/.vim/ftdetect/cheat.vim with this line:
au BufNewFile,BufRead *.cheat/* set filetype=cheat
This loads a simple config file at ~/.vim/ftplugin/cheat.vim:
set statusline=%t
set statusline+=\ %P
set statusline+=%#todo#
set nonumber
It loads fine, but when I source ~/.vimrc the settings for cheat.vim are lost.
The best long-term solution is to avoid having your vimrc overwrite filetype settings if executed directly by using local options and similar, but the simplest fix is often to re-edit the file. Type
:edit
And hit Enter.
This can be shortened to just :e in interactive use, and a mapping is easily created:
nnoremap <silent> <leader>e :edit<CR>
I suggest reading the help pages on vim’s startup, init files, source command, edit command, and the various ways to tune things local to a single buffer (e.g., setlocal, map-<buffer>, autocmd pattern <buffer>).
In my vim editor, I can find two mappings of through following commands:
:imap <CR>
and it outputs:
i <CR> &#<SNR>60_AutoPairsOldCRWrapper73<SNR>60_AutoPairsReturn
i <CR> <CR><Plug>DiscretionaryEnd
I want to disable the first one, so I add it into my .vimrc file:
iunmap <buffer> <CR>
but vim shows error no such mapping error when I open my editor, but actually I can disable the mapping by typing command in editor:
:iunmap <buffer> <CR>
I want to know why I cann't make it work in my .vimrc configuration file.
Plugins are sourced after your vimrc so the mapping you want to disable is not defined when that comand is executed.
That said, the plugin's README tells you how to replace the default mappings. So… read it and experiment.
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.
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.