Tag Info

Hot answers tagged

16

Use the \c escape sequence: /foo\c See also: http://stackoverflow.com/questions/2287440/how-to-do-case-insensitive-search-in-vim


10

In vi or vim you can ignore case by :set ic, and all subsequent searches will consider the setting until you reset it by :set noic. In less there are options -i and -I to ignore case.


6

With a large enough value of 'undolevel', Vim should be able to undo the whole day's changes. If you quit Vim in between, you also need to enable persistent undo by setting the 'undofile' option. Vim captures not just a sequential list of commands for undo, but actually a tree of all changes. It also has several commands around undo (cp. :help ...


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

Copy the content to your document in vim as you do, presumably with the middle mouse button in X, using insert mode, but on separate lines. Then go to the first column of the first of the newly inserted lines and go into visual block mode CTRL+v where you can select the content. The only issue here could be different line lengths that sometimes make it hard ...


4

You are already re-logged in with the new ssh session that you set up. If you want to connect the old edit session to you newly logged in session you can try reptyr which "reparents a running program to a new terminal". If this disconnecting happens often there are multiple things you can do: set ServerAliveInterval and/or TCPKeepAlive in ...


4

Just match anything (.*) between the start and end patterns: /^start123.*321end$


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

With my UnconditionalPaste plugin, you can force the paste to be blockwise, which is what you want here. So instead of entering insert mode and pasting with the middle-mouse button (which I suppose you've done), use the "* register together with the plugin's gbp mapping.


3

First, let's look at what we see in the terminal: $ echo <(vim) /dev/fd/63 $ Vim: Warning: Output is not to a terminal Notice that you get a prompt back immediately, without waiting for the editor to terminate. Process substitution doesn't wait for the command to finish, it creates a pipe between the command and the shell. A name for that pipe is ...


3

The built-in spellfile.vim script will attempt to download missing spell files from http://ftp.vim.org/vim/runtime/spell. In general, spell checking is not supported for East Asian languages like Chinese and Japanese, because individual words are not separated by whitespace, so a different algorithm would be needed. You probably want to :set ...


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


2

If you have xclip (sudo apt-get install xclip or similar) you can access the system (i.e. Xorg) clipboard from the command line, using xclip -o. This way, you can !paste - <(xclip -o) or define a key mapping (for instance <LEADER>p) as: :map <LEADER>p .,$!paste - <(xclip -o)<NL> and use <LEADER>p to paste the current X ...


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.


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

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

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


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


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


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

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


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


1

Starting gvim opens a new window, so the terminal window stays available for commands. For intermediate "shell escapes" I do :sh to get access to a shell session, and type <Ctrl>-D to exit it; no fg is needed, but a prompt is added in this case to the console shell. And with no X running I start two consoles, one where vim is running, and the other ...



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