Hot answers tagged

5

The vim command line switch -c will execute vim commands. You can pass multiple commands and passing the two following commands will start help, in only one window vim -c help -c only


4

You could issue the command: :intro


4

You almost got it right, you just forgot to match the rest of the line (on vim): :%s/^hardware mac.*/hardware mac 00:00:00:00:00:00/gc You can drop the gc options at the end if you are sure of what you are doing, g is likely to be unnecessary since you won't match more than once per line. With sed it is the same thing: sed -i 's/^hardware mac.*/hardware ...


4

:%s:.*:<a href="&">&</a>: Same as in ed/sed/perl... Another less ex and more vim-like way would be: if you know how to do it once for a line, record it as a macro and then run :%normal @m where m is that macro. Like (in normal mode): qmS<a href="<Ctrl-R>""><Ctrl-R>"</a><Esc>q to record the macro.


4

You don't need the second !. It should be just: :'<,'>! sort -f | uniq From :help :!: Any '!' in {cmd} is replaced with the previous external command (see also 'cpoptions'). But not when there is a backslash before the '!', then that backslash is removed. Example: ":!ls" followed by ":!echo ! \! \\!" executes "echo ls ! \!". A '|' in {cmd} is ...


3

The :intro command displays the welcome screen.


3

It's the command-line window (keyboard shortcut q:, quit with ctrl+c,ctrl+c) It shows a history of your previous commands, which you can navigate to and edit with normal (command) mode. Once you've finished you can hit enter to run the edited or reselected command. A similar history window is available for searches (keyboard shortcut q/, quit with ...


3

-o, -O, and -p are mutually exclusive. You can't combine them. From main.c, command_line_scan(): case 'p': /* "-p[N]" open N tab pages */ parmp->window_layout = WIN_TABS; break; case 'o': /* "-o[N]" open N horizontal split windows */ parmp->window_layout = WIN_HOR; break; case 'O': /* "-O[N]" open N vertical ...


3

If you have the rename implementation with Perl regexes (as on Debian/Ubuntu/…, or prename on Arch Linux), you need $1 instead of \1. Also, no backslashes on capturing parentheses: rename 's/(.*)_(.*)/$2_$1/' *_* If not, you have to implement it yourself. #! /bin/bash for file in *_* ; do left=${file%_*} right=${file##*_} mv "$file" ...


2

vim treats a sequences of [A-Za-z0-9_] or sequences of non-blank characters separated with white space as a word, sequences of non-blank characters separated with white space as a WORD. You can re-define what word mean to vim: set iskeyword-=_ Now place your cursor at e, press d+w or d+e


2

I've made a script to grep recursively for a pattern, and then I can select one of the matches so vim will open that file in that line. I call it vgrep (vim grep, although it uses also awk in it). The following is its code: #!/bin/bash my_grep() { grep -Rn -I --color=auto --exclude-dir={.svn,.git} --exclude={tags,cscope.out} "$@" . 2>/dev/null } ...


2

statusline can be modified to include variable names. For example, I'm using the statline plugin, so my statuslineis: statusline=[%{StatlineBufCount()}:%n] %<%1*[%f]%*%2*%h%w%m%r%* %y[%{&ff}%{g:statline_encoding_separator}%{strlen(&fenc)?&fenc:g:statline_no_encoding_string}] ...


2

A command line program can take input from a user via two sources: from stdin (which you are piping to), and by attaching directly to the TTY. Bad things can happen when these are mixed up. Vim does not want to read input from a pipe, it wants you, the user, directly. So let's give it the real stdin back. As a solution, we can use a command substitution to ...


1

why do you use the Pipe? :%s/.*/\<a href=\"&\"\>&\<\/a\>/g (mark all command strings with \ )


1

You can remap your paste command to LEADER + p nnoremap <leader>p :set paste<cr>p:set nopaste<cr>


1

You just forgot to place a % before your s command: :%s:one:two:e | %s:three:four:e | %s:five:six:e The % makes vim to search your whole text instead of just the current line.


1

From within the vi/vim/gvim editor, you can open a file by typing :e fileName (or instead of fileName you can use path/to/fileName, absolute or relative). For the multiple file view (multiple-tab idea), first do one of the following: ctrl+s for a horizontal split ctrl+v for a vertical split Use ctrl+w+w to switch between panes


1

There are two ways you could do this: run vim in a screen session, and attach to that from different terminals run vim in client/server mode Further reading: Taking Command of the Terminal with GNU Screen Using GNU Screen to Manage Persistent Terminal Sessions Server and client mode in Vim How does vim support C/S mode?


1

If you want REALLY want this, you should use one of these after enter :help : :tab split Or :tabedit % And this will make a new copy of the current page(help) be positioned on a new tab. If you want to move, hit Ctrl-W (release) Shift-T will do the trick. I think that this key combination is what you really want. If you want to be proactive and open ...



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