I have no idea how got into my vim configuration, and its behavior is very wired.
:verbose imap
get
i <C-R><C-R> * <C-R>*
Last set from ~/.vim/plugin/keymapping.vim line 43
! <D-v> <C-R>*
Press ENTER or type command to continue
What is ! <D-v>? Why it has no file path?
BTW, in my .vimrc, I did set nocomapatible and using iterm 2.
What is ! <D-v>?
From :h key-notation:
<D-...> command-key (Macintosh only) *<D-*
So, <D-v> is just ⌘+v
And prefix ! in the imap results indicate that it's applicable for both insert mode and command-line mode.
Why it has no file path?
Because this is vim built-in mapping, not set by user or a plugin and is coming from stand mac mappings. check :h mac-standard-mappings.
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.
Sorry if this is a silly question, I'm brand new to Vim.
I've downloaded the following shebang plug-in (http://www.vim.org/scripts/script.php?script_id=3366 version 1.1) to the directory .vim/plugin
When I open a file (e.g. "vim pypr.py") and in type in ":\X [enter]" (in normal mode) I encounter the following error:
"E10: \ should be follow by /, ? or &"
My .vimrc file in its entirety is as follows:
execute pathogen#infect()
syntax on
filetype plugin indent on
syntax enable
set background=dark
colorscheme solarized
map <leader>X :w<CR>:call SetExecutable()<CR>
I googled the error, and the results were not helpful in resolving the problem.
Any ideas what I'm doing wrong? I suspect I just don't know how to use the leader command.
The mapping
map <leader>X :w<CR>:call SetExecutable()<CR>
says to enter \X where \ is leader's default value. You can find the current leader value by
:let mapleader
It is \ if it says Undefined variable or it will show the current leader value.
Or you can map to another key like F6 so that pressing F6 will achieve what you are looking
nnoremap <F6> :w<CR>:call SetExecutable()<CR>
With mapping you don't need : and [Enter] — just type \X.
The tutorial gives this example:
<leader>c$ |NERDComEOLComment|
Comments the current line from the cursor to the end of line.
But pressing \c$ or ,c$ in vim copies the current line and switched to insert mode.
I've installed the plugin via pathogen and :help nerdcommenter does work, but there's no mention of nerdcommenter in the output of :scripts, don't know if that means the plugin hasn't been successfully installed.
This looks fine. Here are some troubleshooting tips:
Check the :scriptnames output for .../plugin/NERD_commenter.vim; it needs to be there.
Check :echo loaded_nerd_comments
Check :echo g:NERDCreateDefaultMappings
Check :nmap <Leader>c
Do other mappings work? Define :nmap <Leader>x :echomsg "Works"<CR> and press \x.
If mappings don't work, you may have accidentally :set paste. Undo with :set nopaste.
I am trying to map the '-' key to move a line down
in my vimrc I have
noremap - :m .+1 <cr>
but the carriage return is ignored and displayed in the terminal as <cr>
After reading Vim ignores <cr> i tried adding an additional <cr> but that just echoes the characters twice.
So after pressing the '-' key I have to physically press the <enter> key to get the command to run.
I have tried this in mac and linux and get the same results.
It works if I set nocp.
I haven't come across any instructions that this must be set for <cr> to work.
So this is the issue.
set nocp is set if a vimrc is detected.
if you are testing a custom vimrc and starting vim with vim -u mycustomvimrc then despite the fact it is loading a vimrc file it does not set nocp and maintains backward compatibility. In such cases you need to set nocp explicitly.
Thanks for all the suggestions to get this resolved.
Using a spanish keyboard layout like this one:
(source: terena.org)
I'm trying to map in my .vimrc the ñ to : in normal mode and the º in the upper left corner to <esc> in insert mode but it is not working. I've tried with imap and inoremap on my .vimrc like:
nnoremap ñ :
inoremap º <esc>
I've tried with Vim 7.4 both on Linux and Windows (gvim on Windows). The odd thing is that if I do the remaps in normal mode instead of in the .vimrc file, they work. It's like these chars are treated differently inside the normal mode command line, in fact after loading the .vimrc a :nmap ñ returns "No mapping found".
You can check my current .vimrc here: https://github.com/juanjux/My-Vim-dir/blob/master/.vimrc
DavidEG gave me a hint that led me to the working solution.
Comment or remove any set encoding= lines in the .vimrc file
Restart Vim
Add the maps to your .vimrc file. Save.
Uncomment the set encoding= lines.
This worked for me on Linux and Windows.