Hot answers tagged

7

I'm going to say this is not possible because vim is not executing remote commands. It is simply using scp to copy the file over, edit it locally and scp it back when done. As stated in this question sudo via scp is not possible and it is recommended that you either modify permissions to accomplish what you're wanting or just ssh across to the remote machine....


4

Like the accepted answer, I don't think this is possible directly. However, I see at least two ways to still accomplish your goal. Running vim remotely ssh user@myserver sudo vim /some/file This has disadvantages: Your interactions with vim go over the network. Significant lag will be annoying, and if your connection dies, so does vim (eventually). ...


3

You're almost there, but your regular expression is replacing both the newline and the non-digit with a tab. How about replacing every newline followed by a non-digit with a tab and that same non-digit? %s/\n\(\D\)/\t\1/g The escaping is a bit messy, but basically you have a grouping around the \D that will capture whatever the non-digit is. This is then ...


3

In my answer I will not concern myself with Vim, but instead look at the underlying mechanisms, that you have stumbled upon. It is important to understand these, as it affects the security of your entire system. It has nothing to do with owner: try it, make a file not owned by you, then give your self read not write. You will get the same results. So why is ...


3

With "wq", "!" asks Vim to ignore the read-only attribute. From the documentation: :wq [++opt] Write the current file and quit. Writing fails when the file is read-only or the buffer does not have a name. Quitting fails when the last file in the argument list has not been edited. :wq! [++opt] ...


2

You would need the root password or have your public ssh key in ~root/.ssh/authorized_keys. Once you had that, you could probably do vim scp://root@nagios//tmp/notouch Bottom line: this is effectively just a shortcut for scp root@nagios:/tmp/notouch /tmp/notouch vim /tmp/notouch scp /tmp/notouch root@nagios:/tmp/notouch If you have the necessary access ...


2

By modifying the line (line 406)... call s:X("Special","799d6a","","","Green","") in the jellybeans.vim file you can change the escape character color in strings. Simply replace 799d6a with the hex color code you want the escape character to be.


1

One way to do it is to use the end match marker: %s/\n\ze\D/\t/ Another way to do it is to using negative lookahead: %s/\n\d\@!/\t/ They are not exactly equivalent, the second will also replace the last newline in a file.



Only top voted, non community-wiki answers of a minimum length are eligible