1

I'm using basic version vimrc from https://github.com/amix/vimrc. No problem if I put the vimrc file to /home/{user}/.vimrc, but if I put it in /etc/vimrc (arch) or /etc/vim/vimrc (debian), it became problems.

The problem is: I cannot use:

let mapleader = ","

And then use the mapping function that use the leader:

map <leader>tf :tabnew **/*    "fuzzy search file and open in new tab
map <leader>tn :tabnew<cr>     "open a blank new tab

Or just mapping a <space>:

map <space> /
map <c-space> ?

In my arch workstation, I open it from konsole. In my debian server, I ssh-ed to it (so, a tty).

Any suggestion? Thanks.

Edit (more information) with command :map with global vimrc (from @statox link):

   0             ^
   <Leader>m   * mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
v  <C-S-k>       :m'<-2<cr>`>my`<mzgv`yo`z
v  <C-S-j>       :m'>+<cr>`<my`>mzgv`yo`z
n  <C-S-k>       mz:m-2<cr>`z
n  <C-S-j>       mz:m+<cr>`z
   <leader>cd    :cd %:p:h<cr>:pwd<cr>
   <leader>te    :tabedit <c-r>=expand("%:p:h")<cr>/
   <leader>tf    :call fzf#run({'sink': 'tabedit'})<cr>
   <leader>tc    :tabclose<cr>
   <leader>tn    :tabnew<cr>
   <leader>tz    :tabnew **/*
n  <c-space>   * ?
n  <space>     * /

So, most of the keys are not mapped correctly except a few like map 0 ^

And this is :map command when I drop the vimrc to ~/.vim/vimrc

   0             ^
   ,m   * mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
v  <C-S-k>       :m'<-2<cr>`>my`<mzgv`yo`z
v  <C-S-j>       :m'>+<cr>`<my`>mzgv`yo`z
n  <C-S-k>       mz:m-2<cr>`z
n  <C-S-j>       mz:m+<cr>`z
   ,cd    :cd %:p:h<cr>:pwd<cr>
   ,te    :tabedit <c-r>=expand("%:p:h")<cr>/
   ,tf    :call fzf#run({'sink': 'tabedit'})<cr>
   ,tc    :tabclose<cr>
   ,tn    :tabnew<cr>
   ,tz    :tabnew **/*
n  <c-space>   * ?

migrated from serverfault.com Sep 16 '18 at 15:42

This question came from our site for system and network administrators.

  • What is the error message you got? – tivn Sep 16 '18 at 16:10
  • there's no error message. It just the 'shortcut' is not functioning. – tonny Sep 16 '18 at 18:56
  • 1
    You need to specify clearly what you expect, what you type, whether the mapping is used before you apply the foreign vimrc or not. I see <leader>tf is not in the foreign vimrc while map <space> is. – tivn Sep 17 '18 at 2:50
  • 2
    Also I don't think that putting your complete vimrc in /etc is a good idea: your vimrc contains your mappings and your configurations, other users don't need such a complete generic vimrc (since they can override it with their own vimrc). And if you do that so you can have your configuration when editing a file as root, don't edit files as root use sudoedit instead. – statox Sep 17 '18 at 9:26
  • 1
    @tivn vim does in fact read ~/.vim/vimrc (theres a specific order it searches in though) – D. Ben Knoble Sep 17 '18 at 13:01
0

I'll list my alternative ideas that doesn't solve the actual problem:

  1. put the vimrc file elsewhere (prefer in /etc/skel/.vim/vimrc) then make a softlink to local .vim/vimrc. The command: mkdir .vim && sudo ln -s /etc/skel/.vim/vimrc .vim/vimrc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.