Tag Info

Hot answers tagged

26

You can use another character instead of slash / as delimiter to substitution command. Example using #: :%s#/a/b/f/g/d/g#/s/g/w/d/g/r#


4

You can use the vim command :X to encrypt the file. It will prompt you for an encryption key, twice. Then save the file as normal. If someone tries to read the file (including root user), it will be gibberish: Mark@MarkBeast ~ $ vim test.txt Mark@MarkBeast ~ $ cat test.txt VimCrypt~01!o▒rl▒_▒Ĩ7vE=▒g Mark@MarkBeast ~ $ When you vim the file later, it ...


3

I don't think you can map CapsLock from within Vim. You remap it within X using setxkbmap: setxkbmap -option caps:swapescape For remapping in the console, if your distro uses systemd, you can use a custom keyboard layout in /etc/vconsole.conf as described on the Arch Wiki, and for other init systems see this U&L answer.


2

Maybe you can use sed Example 1 – sed @ delimiter: Substitute /opt/omni/lbin to /opt/tools/bin When you substitute a path name which has /, you can use @ as a delimiter instead of /. In the sed example below, in the last line of the input file, /opt/omni/lbin was changed to /opt/tools/bin. $ sed 's@/opt/omni/lbin@/opt/tools/bin@g' path.txt ...


2

What you can do is use :redir to write them out to a file and then edit them: :redir > variables.vim :let g: :redir END :n variables.vim or use variables.vim as input to some other command.


2

Vim can get close(r) to an IDE in terms of features via various plugins, but it will always remain a powerful text editor with great extension capabilities. So for anything larger than a hobby project, you'll certainly miss IDE features like debugging, variable inspection, refactoring, find usages, etc. But why not have both? It's easy to set up a command ...


2

There is a plugin called CodeOverview that can be used on windows (and Mac?): http://www.vim.org/scripts/script.php?script_id=2888?


2

The NrrwRgn - A Narrow Region Plugin similar to Emacs plugin can show parts of the buffer in a separate scratch buffer, with automatic syncing back. That looks like a solution when you're concerned about moving away from the view. Otherwise, I would just size a split window to show exactly what you want, and keep it at that.


1

You can change the permissions on the file to 000. $ chmod 000 somefile Example Initially we have this file: $ cat afile secret Change the permissions, and confirm: $ chmod 000 afile $ ls -l afile ----------. 1 slm slm 7 Nov 26 13:07 afile Now we can't see it: $ cat afile cat: afile: Permission denied Caveats with this This is easy to ...


1

This happens when TERM isn’t set to the correct screen[-256color] in Vim’s environment, usually by some shell startup script. If that is the case – for example, you have a TERM=xterm-256color , either remove it or make sure it checks the original value of TERM before changing it, e.g. if [[ $TERM == xterm ]]; then TERM=xterm-256color fi


1

I needed two autocmds to do this. To reach the gap between the headers and the message, search for an empty line: autocmd BufRead /tmp/mutt-* execute "normal /^$/\n" then to enter insert mode: autocmd BufRead /tmp/mutt-* execute ":startinsert"


1

You'll have to live without ctrlS because that is the terminal command to stop output (ctrlQ undoes that). Other function keys should be mappable without any problem, just enter :map , then hit the function key you want to map which should show e.g.<F5> for F5, then space, then what you want the key to map to. You can put that line (without the ...


1

First, you need to know what ci" mean in vim: c means change i means inside " means double quote literal text object. So, ci" means change a string inside quotes. Adding 2 applied change command over 2 quotes.


1

I suggest you read doc/motion.txt. It states that with count 2 the quotes are included and thus i" works a bit like a" except no extra whitespace is added. EDIT: Just to be clear, I don't strictly speaking provide an answer. I take this behaviour as the design decision of the author and since he did not provide rationale in the manual, you can only ask ...


1

I found that this happens when I enter netrw (with :Explore, for example) and press O on a file, it attempts to "obtain" this file resulting in an error message and this text being appended to my status line. I haven't found a way to get rid of it other than to use :set, copy out the normal status line, and re-set my status line to the proper one without ...


1

This is a buffer flush-to-disk problem. Vim tries to keep your work safe and doesn't assume you can type several thousand characters per second. Read :help swap-file for some details on the buffering. The solution to your problem is this: Turn off vim's swapfile either with: vim -n <your file> or from within vim before the paste: :set noswapfile ...



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