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.
Related
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 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.
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.
As stated in the question, my vim starts out in delete mode. If I open a file and hit j to start navigating, that'll delete the first line.
I've isolated the problem down to this line in my .vimrc:
nnoremap <silent> <esc> :noh<return><esc>
I don't understand why this would even trigger delete mode. On top of that, I believe I added <silent> to instruct vim to make this binding without executing it, which doesn't seem to be the case.
What's the explanation for why this is happening?
(side note, this mapping is to tell vim to clear search highlights when I hit esc)
If you run this command in terminal:
$ vim file.txt -c 'nnoremap <silent> <esc> :noh'
It'll show this at the bottom:
:noh[>1;3201;0c
vim enters change-mode somehow.
You can change <esc> to <F5>(or other keys).
If you use gvim, there's no problem.
It's caused by terminal special key escaping.
When I use the arrow keys in vim in insert mode I get letters inserted instead of movement.
Up produces an A
Down produces a B
Left products a D
Right produces a C
Does anyone know what would cause this?
Thanks in advance
If these keys work fine in normal mode, but do not in insert then you must have some mappings to the first one or two characters (normally <Up> is either <Esc>[A (terminals that use CSI) or <Esc>OA (xterm)). Try checking out output of
verbose imap <Esc>
, there should be not much mappings starting with <Esc> in insert mode (I have none, for example). I can say, that with arrow keys working normally in insert mode, using
inoremap <Esc> <Esc>
produces just the same behavior as if you had problems with terminal recognition or had 'compatible' set.
Your vim seems to be starting in the vi compatibility mode. Do this
Open Vim editor,
Get the path of your home directory by typing :echo $HOME
Check if you have .vimrc file in $HOME location,(if you don't have create it)
Add the following line line to .vimrc file
:set nocompatible
Find more solutions for the same problem here ( Especially if your problem is terminal related, the re-mapping of keys solution might work for you )
The following worked for me. Just put it in your .vimrc
:set term=cons25
Open Vim editor.
Get the path of your home directory by typing: :echo $HOME.
Check if you have .vimrc file in $HOME location, and if you don't have create it.
Add the following line line to .vimrc file: :set nocompatible
Reference: http://vim.wikia.com/wiki/Fix_arrow_keys_that_display_A_B_C_D_on_remote_shell
None of the answer here worked for me. I'm in Linux, with konsole/yakuake terminal and tmux. This fix works for me:
nnoremap <silent> <ESC>OA <ESC>ki
nnoremap <silent> <ESC>OB <ESC>ji
nnoremap <silent> <ESC>OC <ESC>hi
nnoremap <silent> <ESC>OD <ESC>li
inoremap <silent> <ESC>OA <ESC>ki
inoremap <silent> <ESC>OB <ESC>ji
inoremap <silent> <ESC>OC <ESC>hi
inoremap <silent> <ESC>OD <ESC>li