Tag Info

Hot answers tagged

40

There're two reasons: Auto insert comment Auto indenting For pasting in vim while auto-indent is enabled, you must change to paste mode by typing: :set paste Then you can change to insert mode and paste your code. After pasting is done, type: :set nopaste to turn off paste mode. Since this is a common and frequent action, vim offers toggling paste ...


19

zsh like most modern shells have a choice between two different keyboard mappings for command-line editing: a vi one and an emacs one. In some shells (like tcsh or readline-based ones like bash), the emacs one is the default and probably the one you expect. With zsh, you get emacs mode by default unless $EDITOR or $VISUAL contains vi (if you're a ...


14

Use the vim paste. What you want is to paste what is on the clipboard buffer "+p This selects the + and pastes it in place. If your using Linux * is the x buffer (the last selected text) Then vim knows its a paste What happens otherwise is vim thinks you have typed the keys being pasted (which include the indentation combined with vim doing auto ...


11

Because the way you define it py is a shell alias, and Vim doesn't know (nor care) about shell aliases. Use an environment variable instead, perhaps like this: $ PY=/opt/python3.4/bin/python3 $ export PY then in Vim: ... exec '!time ' . fnameescape($PY) . ' %' ... Edit: Added fnameescape(). It's needed if $PY contains characters that have a special ...


5

The tabs were inserted because you have autoindent turned on and you can disable that behavior by turning off autoindent (:set noai) before you paste into terminal. The commented lines are produced by auto commenting and can be disabled by turning that off. Alternative to those you should get the desired behavior using the toggles :set paste, pasting ...


5

As @lcd047 told you, aliases are not available to vim. They are also, by the way, not available to shell scripts either, unless you activate the expand_aliases option. Anyway, another choice would be to create a link instead of an alias: sudo ln -s /opt/python3.4/bin/python3 /usr/bin/py That will create a link at /usr/bin/py which points to ...


5

For yanks, Vim supports setting both unnamed and unnamedplus: :set clipboard=unnamed,unnamedplus From :help clipboard-unnamedplus: When "unnamed" is also included to the option, yank operations (but not delete, change or put) will additionally copy the text into register '*'.


4

In Vim, you could limit your substitution to the lines that contain NX: :g/NX/s/N1/NX/ Preceding the substitution with /NX/ makes Vim perform it only on the next line that contains NX (using ranges), and using :g makes it run on all lines that match NX.


3

You can find out which colorschemes are installed (and try them out) via :colorscheme <Tab> (or <C-D>). If you've found a nice one, just :edit ~/.vimrc and put the corresponding command in there. Some colorschemes look better if you have a high-color terminal. You can find out the number of available colors via :set t_Co?; you can also try ...


3

CTRL-] means hold down control and hit the ] key (not -).


3

You can use :help usr_01.txt to access a specific file. Usually more usefully you can jump to a particular topic: :help syntax :help wq :help CTRL-] This last notes that you can also use Ctrl-Click with the mouse, and double-click works too. You can also use g] to access tagselect, which offers a list that you can select from with just numbers and ...


3

When you make an <A-x> mapping in Vim when x is a printable character (i.e., not a cursor or arrow key), it tells Vim to expect that character with the 8th/high bit set (aka, add 128 to the ASCII value). In your example, <A-h> means Vim will trigger the mapping when you type è. The ASCII value of h is 104 (binary 01101000) and when you set the ...


2

The two vim instances are completely separate from each-other, but there are two possibilities to do this. If your version of vim was compiled with X clipboard support you can use eg. "+yy to yank the current line to the X clipboard register, alternatively putting set clipboard=unnamed in your vimrc to yank to the clipboard by default. See :help registers ...


2

A generic awk alternative: awk ' /^uid:/ { uid=$2 } /^homeDirectory:/ { if ($NF !~ uid"$") { $NF = $NF"/"uid } } { print } ' text.file


2

This happens because your first capturing group does include the spaces. ^\([^#]*\)\(#.*\) | -------- -------- the comment begin | everything upto # including spaces To fix it, you want to leave the spaces out of the capturing group, like so: ^\(.\{-}\)\s*\(#.*\) | ------ -- ------ comment begin | \____ any amount ...


2

It is possible to enable the /g flag on :s substitutions by default by setting set gdefault in .vimrc. If this is set using :%s/PATTERN/gn will cause Vim to count occurrences of chars or words once per line and ignore all other occurrences. Either use :%s/PATTERN/n in this case or remove set gdefault from .vimrc.


2

Paul’s answer above explains how to jump from link to link in the vim help, but you can also open the file directly, if you know what you want to open, with eg, :help usr_01.txt


2

You can use xdotool to set window's WM_WINDOW_ROLE property: $ xdotool set_window --role <ROLE_STRING> <WINDOW_ID> You can find WINDOW_ID by PID: $ xdotool search --onlyvisible --pid <PID> Note that there is a harmless bug message printed in xdotool 2.x when using this method: $ xdotool search --onlyvisible --pid 16076 Can't consume ...


2

As @VincentNivoliers said in his comment, your issue comes from the line mouse=a. It enables the mouse in all modes of vim, ie letting you put the cursor where you click. a means this is active in all modes. If you don't want vim to care about your mouse, just set mouse= (no value). Then, you could use your mouse to copy'n'paste from your clipboard as in a ...


2

.exrc is the configuration file for vi, whereas .vimrc is the config file for vim No. Vim will use the .vimrc file if present, otherwise the .exrc file if present Yes, unless you only put vi-compatible commands in there From the Vim help on exrc: c. Four places are searched for initializations. The first that exists is used, the others are ignored. ...


2

If you need to enter non-ASCII text, try changing your mappings in vim from <A-x> to <Esc>x. If you enter only ASCII text, you may try launching urxvt with --meta8 option, and in vim set termencoding=latin1. You may also try other solutions from: http://vim.wikia.com/wiki/Get_Alt_key_to_work_in_terminal


1

The colorscheme also needs to support (high color) terminals. For the one referenced in your ~/.vimrc, wombat, this one only supports the GUI (there are only guifg= / guibg= attributes). There's a special version of wombat for 256-color xterm, here. Alternatives Plugins like CSApprox can take the GUI color definitions and convert them to a closely ...


1

The GPG man page has several options you're probably interested in, that you could work into your own personal decrypt-edit-encrypt script/function. Like: --passphrase-fd n - Read the passphrase from file descriptor n --passphrase-file file - Read the passphrase from file file... Obviously, a passphrase stored in a file is of questionable ...


1

I don't know of any way to do what you want with the standard tools. That said, a really simple wrapper script could accomplish this. Alternatively, if youre on Linux, you can use pyrite, which is a GUI wrapper for gpg & openssl. With it, you can type your password into the GUI a single time to decrypt, edit the decrypted text, and then press a button ...


1

Changing the semantics of the diff command indeed wreaks havoc on Vim (this is explained under :help diff-diffexpr: The output of "diff" must be a normal "ed" style diff. Do NOT use a context diff.), and potentially other programs, too. A pure shell alias with the same name is fine, as that is only considered when you type commands interactively (or in ...


1

Inside tmux, you need to set TERM=screen-256color. It may be something like here that this only works from inside tmux, but not in tmux.conf. Check that you don't unconditionally overwrite the TERM value, e.g. in your .bashrc, or anything that gets sourced when you open a shell inside tmux.


1

Usually *BSD provides different options for compiling a program, these are usually called flavours, this is also true for most Linux distributions. Read the Makefile in the directory of the port to see what options are available. Vim can be compiled with many features, for example, you may be in an environment where X11 isn't installed, so you have no need ...


1

This will do: /^[^']*\%('[^']*\)\{4}$ It searches for a quote followed by any non-quotes ('[^']) four times (\{4}; here, you can also specify ranges like \{2,5}). To ensure that the exact number matches in the line, the pattern is anchored to start (^[^']*, with optional non-quotes in front) and end ($, trailing non-quotes already included in the ...


1

By default, select the text and then you can use "+y See the help for the clipboard, :h clipboard.


1

In case there's always data to collect for 7 entries (plus a blank line) then this awkprogram will collect the respective data and print them at the end: awk '{a[NR%8]=a[NR%8]" "$0} END{for (i=1;i<=7;i++) print a[i]}' (Note that your data samples seem to have a lot of trailling blanks; if you want those blanks removed instead of joined, please adjust ...



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