New answers tagged

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] ...


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). ...


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 ...


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....


0

The tmux approach is to use three sessions: an outer session for the panes, an inner session for the windows (you can attach to this from one pane), a secondary view onto the inner session (for the other pane). Yes this is UNIX philosophy gone mad. Let's get started. # Create a session to hold the multiple windows $ tmux new-session -s inner <...


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.


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 ...


-2

I hope this will help you :%s#\n.\D#\t#g


0

function! checkifrunning(mystring) if !system('pgrep "' . a:mystring . '"') " --do something-- endif endfunction Technically ! operates on Numbers, and converts a String to a Number first if given a String. However, if there's no process running, the output of pgrep will be empty, which when converted to a Number is 0. If there are process ...


0

You can use like :call system("pgrep process name ") To print the output , :echo system("pgrep process name ") You can store the output in a variable like :let a=system("pgrep process name ") And, use that variable in any loop, print, or use string functions as well.


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 ...


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 ...


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 ...


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 ...


0

If you do not specify the cursor color, xterm will draw the cursor using the reverse of the foreground/background colors on the cell where the cursor happens to be. That's for xterm. Other programs do not behave that way. This is what the xterm manual says: cursorColor (class CursorColor) Specifies the color to use for the text cursor. The default ...


0

I don't know anything about vim so my response may be a non starter, but many years ago vi was considered a good skill because you could do everything with keystrokes so you were still ok if you didn't have a functional mouse.


0

Vim ~/.vimrc: set t_Co=256 colorscheme <name> Tmux ~/.tmux.conf: set -g default-terminal "screen-256color" Shell After the previous changes, you should adapt your workflow to one of these options: Option #1: always start tmux with the -2 argument: tmux -2 Option #2: set up an alias in your shell config file (~/.bashrc, ~/.zshrc): alias ...


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


0

It seems that you might have used numeric keypad. For me also, pressing / in numeric pad shows <F2> in command line. It is mapped by default. You can type :set termcap and look for t_K8. That will show <kDivide>. Solutions: 1) pressing / near to shift key instead of the other one. 2) setting termcap of t_K8 to /. 3) Mapping <kDivide> ...


0

You have given a space after ^[ in second part. If you put the command without a space, it works in the way you wanted. :normal A Append^[yyp


0

To expand on Caleb's answer just slightly, vi{ will select the "inside" of the code block. To include the "outside" of the code block, ie including the braces, use va{. This won't include the while stanza though. To do that you can use o to move the cursor to the beginning of the selection, and then 0 to move the selection to the beginning of the line.


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.


0

You can try this plugin. https://github.com/tpope/vim-abolish This plugin can help you to match not just the case sensitive text, also its variants too. Like /good{,ies} will match both good as well as goodies. Similarly, it can replace with case sensitive as well as variant included. :%S/long/short/g will replace long with short, Long with Short,...


1

This is how its done in .inputrc: set editing-mode vi $if mode=vi # these are for vi-command mode set keymap vi-command # unbind space " ": "" # bind space-a, space-; " a":beginning-of-line " ;":"$" $endif


0

The cd should not be required. The following line should do the same. /WebSphere/was85/mycel/mynode/AppServer/java_1.7_64/bin/java -cp \ /usr/my.jar com/com.my_comapny_witt_entire_name/myMain I broke the command line into two lines by using backslash continuation. There must be no characters between the backslash and the newline for continuation ...


1

To start with, it's better to always check the exit status of cd, so cd /WebSphere/was85/mycel/mynode/AppServer/java_1.7_64/bin && ./java -cp /usr/my.jar com/com.my_comapny_witt_entire_name/myMain cmd1 && cmd2 means execute cmd2 if cmd1 succeeds. Now I suspect your problem here is that that script is not being interpreted by that OMVS ...


0

Just a backslash cd /WebSphere/was85/mycel/mynode/AppServer/java_1.7_64/bin ./java -cp \ /usr/my.jar com/com.my_comapny_witt_entire_name/myMain



Top 50 recent answers are included