Tag Info

New answers tagged

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


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


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


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


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


0

I assume you're refferring to DtTerm. In this case, you're only limited to 16 colors: despite having a nice GUI, DtTerm is inferior feature-wise compared to xterm, rxvt and others. If you want 256 color support in your terminal, pick a recent xterm build (not the one shipped with Solaris). Another option is using gvim with a Motif/Athena/GTK GUI.


1

Improving @intuited answer to avoid the problem with leading whitespace and growing indent: "Examples: ":call Exec('buffers') "This will include the output of :buffers into the current buffer. " "Also try: ":call Exec('ls') ":call Exec('autocmd') " funct! Exec(command) redir =>output silent exec a:command redir END let @o = output ...


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


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


18

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


0

For emulation issues, it's the version of the vte library that really matters. It received many relevant fixes around version 0.36; I'm afraid you're using an older one.


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.


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


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


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


3

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


1

Old question, but the cleanest solution for vim in zsh was to add the alias to ~/.zshenv, the file that zsh loads for all shells, login, interactive, or otherwise. This avoids starting vim or zsh with flags and any possible problems with that. There's a nice explanation of ~/.zshenv vs ~/.zshrc here: http://tanguy.ortolo.eu/blog/article25/shrc Basically, ...


0

I had to do this to disable mouse (only tested in MacVim): noremap <LeftMouse> <Nop> noremap <2-LeftMouse> <Nop> noremap <3-LeftMouse> <Nop> noremap <4-LeftMouse> <Nop> noremap <RightMouse> <Nop> noremap <2-RightMouse> <Nop> noremap <3-RightMouse> <Nop> noremap ...


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


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


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


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


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


0

This awk version will keep entries intact that already have a user ID as part of the homeDirectory: awk -F ": *" ' $1=="uid" { uid = $2 } $1=="homeDirectory" && $2=="/home/myworker/2013" { $0=$0"/"uid } { print } ' infile > outfile (Note: your data should not have trailing spaces. To clean up that as well you can add a command { ...


2

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


0

awk file : $1=="uid" { uid=substr($2,2) ; } $1=="homeDirectory" { printf "%s: /home/myworker/2013/%s\n",$1,uid ; next ;} { print ;} which basically remember uid print a fixed home dir, base on fixed year and last uid. to be called with awk -F: -f tmp.awk < yourinputfile where -F: use : as separator -f tmp.awk use the awk file


0

If you are using gvim you can use the menu: Edit->Copy. If you are using the console version of vim you can use the commands that gvim explicitly notes besides the menu entries; in your case it's "+y. So mark any text with the visual commands, V, v, or Ctrl-V, and then type "+y to put the marked region into the copy/paste buffer.


1

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


0

Not exactly sure what you are asking. It is perfectly normal that, in vim, if you go to the end of a line in insertion mode it position the cursor is on what looks like an empty space at the 'right' of the line, but in command mode (ie after you press escape) this empty space disapears (and the cursor goes back to the previous character). This is because ...


1

This seems to be a problem with the version of vim that comes with OSX. You're better off installing a newer version of vim from homebrew brew install vim Beware if you're using RVM though as Ruby plugins might segfault if you compile them against anything other than the system Ruby. Best this if you use RVM. rvm use system; brew install vim You ...


0

To remove trailing spaces from each line and add empty line at the end: sed 's/\s*$//;$a\\' very.long.text.file which can be piped through awk ' BEGIN{ RS="\n\n" FS="\n"} {for (i=1;i<=NF;i++) A[i]=A[i] s $i s=","} NR%5==0{ for(i in A) printf "%s,%g\n" ,A[i] s="" delete A print s}' which empties memory by each 40th line to be ...


0

gawk ' BEGIN{RS=""; FS="\n"} {for(i=1;i<NF;i++) {a[i]=a[i]" || "$i} } END {for(i in a){ print a[i]}}' (this solution may change the order of the lines; next version keeps line order). Even better, improve it and create a reusable command "vert_transpose" #!/usr/bin/gawk -f BEGIN {RS=""; FS="\n"} l<=NF {l=NF} ...


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


1

Also, FYI, in GUI version of Vim: gui is for formatting (as opposite of cterm) guifg is for foreground color (as opposite of ctermfg) guibg is for background color (as opposite of ctermbg)


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.


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.


1

You don't necessarily need to open the file in vim to do this. You can do it on the command line sed '/NX/s/N1/NX/g' <filename> >> <newfilename> and then rename the <newfilename> to the original file.


1

CTRL+D is meaningless here - it's just another byte. This is because your serial terminal is not configured to handle it. Specifically, you're effectively in raw-mode, or Non-Canonical Input Mode. See the -icanon flag in your stty -a output? That cinches it. Here's how POSIX describes a terminal should consider an EOF character: EOF Special character on ...


0

The command to move to the next window is Ctrl-W Ctrl-W; cp. :help CTRL-W_CTRL-W. There are several more window commands all starting with Ctrl-W: :help CTRL-W. The E486 error results from a search command, with the previously used search pattern. That should not have been triggered by Ctrl-W, but you may have a plugin or mapping that changed this. Check ...


1

The EOT character does not mark the end of a file. A file can contain arbitrary bytes. Typing Ctrl+D on a terminal makes the application think that the end of the file has come. The application does not read a Ctrl+D (EOT) character, it sees an end-of-file indication. The interpretation of Ctrl+D as end-of-input character is performed by the terminal driver ...


1

Bharath's solution, pressing Shift while copying, will do it, but it will copy more than what you'd like to copy in-case of numbering or hash comments. One way to do so even with mouse=a is use visual mode by pressing V for single cursor or Shift+V for full line highlight, and you can move up or down with arrows and use Y to copy or D to cut and that should ...


1

This may be better suited to the vi/vim stack over at vi.stackexchange.com Note that the :silent tag negates hitting enter, so that has to be added after the set of commands to make it run in the command line. I had quite a bit of luck with the following. :nnoremap <F5> :exe ':silent !firefox % 2>/dev/null &'^M^L Please note that you have ...


2

The given output complains about MyColor, but apparently the script's name is /usr/share/vim/vim74/colors/mycolor.vim. Seems like the g:colors_name variable inside the script is using inconsistent case. This may work on Windows, but Linux filesystems (and Vim's lookups) are sensitive to case. Try renaming either to be consistent, then try again.


1

You'll find the full list of Vimscript functions at :help functions; you can also directly go to the help of a particular function via :help submatch(). Many of those have examples (but most aren't applicable / don't make sense in the substitution replacement expression).



Top 50 recent answers are included