Im trying to remap :CtrlP to :ff but I cant seem to get it to work.
Here is what I have tried:
nnoremap ff :CtrlP<cr>
nnoremap <ff> :CtrlP<cr>
Would appreciate the help!
To give more context, im trying to use the method :CtrlP when I open my project by doing: vi .. I am using Nerdtree as well.
It's not possible to remap :CtrlP to :ff, because user-defined ex commands must start with a capital letter. You could map it to :Ff by doing the following:
command! Ff CtrlP
If you want to map it as a normal mode command instead of an ex command, then the first choice you've mentioned should do it.
Related
I'm using GVim 8.1 on Windows 10 with no external plugins.
I have the following set up in my .gvimrc file:
let g:build_file_abs_path = fnamemodify(findfile("windows-build.bat", ";."), ":p:h")
" This build script is a basic wrapper for 'clang.exe file.c -o file.exe' style invocation
let &makeprg=g:build_file_abs_path . "\\windows-build.bat"
nnoremap <silent> <C-B> :cd <C-R>=g:build_file_abs_path<CR> <bar> make! <bar> copen <bar> redraw <bar> cd -<CR>
Now, this automatically opens a quickfix window with the correct compiler output. However, when I press ENTER over the error, the cursor jumps to the buffer for the affected file, yet it is completely blank with a single line. Furthermore, this occurs as I use :cn and :cp commands inside the quickfix window. e.g:
Images showing these two states:
before
after
Please note that:
:verbose nmap <CR> returns no mappings, so there is not conflict there.
I would appreciate it if someone could provide some insight as to how to avoid the buffer becoming empty and actually jump to the error in the appropriate file. Many thanks.
Thanks to Christian Brabandt's comment, I was able to solve the issue. I was misunderstanding the distinction between the working directories of vim and the build script. I made the following changes:
let &makeprg="cd " . g:build_file_abs_path . " && windows-build.bat"
nnoremap <silent> <C-B> :make! <bar> copen <bar> redraw <CR>
I have
nmap <leader>l :bnext<cr>
and
nmap <leader>h :bprevious<cr>
in my vimrc but when I try to use either mapping I get
e492: Not an editor command: BufSurfBack
If I just use :bnext and :bprevious normally it works fine
I am using macvim if it makes a difference
any ideas?
You used :nmap which allows for recursive mappings. Because of this, the first few characters in each mapping (e.g. :bp) are triggering the plugin functions BufSurfForward and BufSurfBack.
Try using nnoremap instead of nmap which will disallow any recursive mappings.
Also, if you don't use the plugin defining the BufSurfForward and BufSurfBack, you could uninstall that plugin.
To use Vim/Python like a calculator one option is executing the following command in gVim:
:pyf[ile] P:\Computer Applications\Python\pi.py
I intend on storing all my py files in the directory P:\Computer Applications\Python\. Can I add something to my _vimrc file so that in the future gVim knows where all my python files are stored and all I need to write is the following?
:pyf[ile] pi.py
Why not use a mapping?
nnoremap <Leader>p :pyf P:\Computer Applications\Python\
You can then press \p (in normal mode) to get the :pyf P:\Computer Applications\Python\ prefix.
References
Mapleader
:noremap
Normal mode
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
I followed the guide here to create vim mapppings. Put the following in my .vimrc file
let mapleader=','
if exists(":Tabularize")
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
endif
The page says when I type ,a= it should tell Tabularize to align my lines. But instead it inserts the character = where the cursor is.
I have Tabularize installed and the :Tabularize command does work when I call it without mapping.
What am I doing wrong?
Your .vimrc file is read and executed before plugins are loaded, so :Tabularize isn't defined.
To find out the exact order in which the various scripts are called at startup you can run the command:
:scriptnames
and you can learn the details about the initialization process with:
:help startup
Make sure that you set your mapleader to ,. Originally it is mapped to \.
To accomplish this add this to your vimrc or type in the command window:
let mapleader=","
Although from your code it looks like you are doing this, you have to make sure that it didn't get reset somewhere. In order to see what it is set to currently type let mapleader in the command window.