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

If you are using vim, you may be able to recover some or all of your deleted text because vim stores the 9 most recent deletions in registers 1 to 9, which are saved to a file called .viminfo in your home directory when you exit vim. This registers saved in ~/.viminfo are global, for all files that have been edited, NOT one set per edited file. So if you'...


3

The problem is twofold. First, tmux by default converts the control-arrow keys from one type of escape sequence to another. So special keys such as controlleft are sent to vim without the modifier, e.g., left. If you use cat -v to see the different escape sequences, you might see something like this ^[OD versus this (outside tmux): ^[[1;5D The line ...


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

You can use awk: awk '{ print > (NR % 2 ? "odd.txt" : "even.txt") }' a.txt This reads from a.txt and appends lines to either odd.txt or even.txt depending on the current line number.


2

You could create your own vim configuration file, and then create an alias for vim to use that file instead of .vimrc: vim .vimrc-cdnszip Put the following contents into this file: source /etc/vim/vimrc source ~/.vimrc set number " any additional confiuguration you might want... Then alias vim to vim -u ~/.vimrc-cdnszip in your cshrc file. I've never ...


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.


1

Commands started in a shell session will have stdout and stderr (standard output and error) connected to that session. You're starting Thunderbird manually (i.e. by typing thunderbird &, not by clicking an icon in a graphical user interface) so its messages to stdout and stderr will arrive in your current shell session regardless of what you're currently ...


1

Most Unix variants support FUSE, which allows programs to define new filesystem types. There are several FUSE filesystems that expose archive contents as a directory tree. This way any application can see archive contents as ordinary files transparently. See Can I store and work with a directory in compressed form? For example, with avfs, you get read-only ...


1

I think you need to use 'colorscheme' rather than 'color' in your vimrc and place it in your local vimrc file (~/.vimrc). Also, you are testing this on python files and vim may need some settings to correctly recognise them. Try adding the following lines to ~/.vimrc: syntax on colorscheme dracula filetype indent plugin on



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