0

I want to open a .c file , that I found using cscope, in vim editor. Normally it opens in vi editor. I have made and edited vimrc file using the command -

  vim ~/.vimrc

The following are the configuration that I have put into it.

1 syntax enable                                                                                                                     
2 set nu
3 set tabstop=4
4 set softtabstop=4
5 set cursorline
6 
7 
8 if has('cscope')
9   set cscopetag cscopeverbose
10 
11   if has('quickfix')
12     set cscopequickfix=s-,c-,d-,i-,t-,e-
13   endif
14 
15   cnoreabbrev csa cs add
16   cnoreabbrev csf cs find
17   cnoreabbrev csk cs kill
18   cnoreabbrev csr cs reset
19   cnoreabbrev css cs show
20   cnoreabbrev csh cs help
21 
22   command -nargs=0 Cscope cs add $VIMSRC/src/cscope.out $VIMSRC/src
23 endif

I found this configuration in a website. But still it isn't working. And also I dont know what most of these lines means.

So, what are the changes to be done ? And can someone explain me the meaning of these lines?

  • You can also check and change the symlink for `vi` (normally symlinked to `ed`) to `vim`. E.g. check `ls -al /usr/bin/vi`. If it is a symlink (and only if it is a symlink), simply change it to point to `vim`, e.g. `# ln -sf /usr/bin/vim /usr/bin/vi`. – David C. Rankin Jul 19 '18 at 05:34
  • @DavidC.Rankin I am not the super user. So I can't remove /usr/bin/vi . Is there any other way? Thanks. – kaushik chatterjee Jul 19 '18 at 05:43
  • Easy way, use an `alias`, e.g. `alias vi='/usr/bin/vim'` (you can set that in your bashrc). – David C. Rankin Jul 19 '18 at 05:52

2 Answers2

1

You have to set your EDITOR or CSCOPE_EDITOR environment variable to vim, not vi.

Example:

$ EDITOR=vim cscope *.c
Shawn
  • 47,241
  • 3
  • 26
  • 60
  • I am not a super user. So I can't change the environment. Is there any other way? – kaushik chatterjee Jul 19 '18 at 05:32
  • @kaushikchatterjee You don't need to be root to change an environment variable. You can do it from a command line on a per-command basis as in the above example, or for all further commands (look up the `export` shell builtin), or for the future in a `~/.profile` file, and so on. – Shawn Jul 19 '18 at 05:58
0

We use neovim which is of similar use case as of vim. And typing following command in terminal works for cscope -

$ export EDITOR=nvim
Aniruddha
  • 50
  • 2
  • 9