You are not logged in.

#1 2011-02-03 20:42:50

chmurli
Member
Registered: 2008-12-23
Posts: 51

[solved] [VIM] question to vim power users about mapping

Hi,
I have just starting using map leaders in vim and I'm love it.
Here are my shortcuts but this method allow to open /etc/rc.conf only in readonly mode.
So how can I open this file to edit like su (when I open vim without sudo)? I have configured sudo to works without password.

" Fast editing 
map <leader>v :e! ~/.vimrc<cr>
map <leader>b :e! ~/.bashrc<cr>
map <leader>r :e! /etc/rc.conf<cr>

Last edited by chmurli (2011-02-04 21:40:08)

Offline

#2 2011-02-03 21:43:35

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [solved] [VIM] question to vim power users about mapping

I use

map ss :w !sudo tee % > /dev/null<CR>

when I open a file that needs 'sudo' for editing.

For some files I have aliases:

[karol@black ~]$ type rc
rc is aliased to `sudo vim /etc/rc.conf'

Last edited by karol (2011-02-03 21:45:57)

Offline

#3 2011-02-04 21:41:11

chmurli
Member
Registered: 2008-12-23
Posts: 51

Re: [solved] [VIM] question to vim power users about mapping

thx It's one way but I have found better one.
plugin vim-sudo is what i had need exactly
http://www.vim.org/scripts/script.php?script_id=729

Offline

Board footer

Powered by FluxBB