Tag Info

Hot answers tagged

9

On terminals that support setting the scrolling region: tailf() ( # args: <file> [<number-of-header-lines>] trap 'tput csr 0 "$((LINES-1))"' INT tput csr "$((1+${2-1}))" "$((LINES-1))" tput clear { head -n"${2-1}" printf "%${COLUMNS}s\n" "" | tr ' ' = tail -n "$((LINES-1-${2-1}))" -f } < "$1" ) (assumes a shell like ...


8

Use vim's filter functionality. Run: :%!cut -b36- to run the contents of your buffer through the cut command, retaining only bytes 36 and onwards. % means to run the entire buffer through and replace its contents with the output, then ! is the filter command, with the rest of the line as the program to run. This doesn't modify the underlying file unless ...


7

You're looking for :set splitright You can also influence this for individual commands, e.g. :rightbelow vsplit


5

With zsh: vim ./**/*(.) Other shells: find . \( -name '.?*' -prune \) -o -type f -exec vim {} + To open only the (non-hidden) regular files (not directories, symlinks, pipes, devices, doors, sockets...). vim ./**/*(D-.) Other shells, GNU find: find . -xtype f -exec vim {} + To also open hidden files (and traversing hidden directories) and ...


4

You can use the last jump mark (m') as a temporary mark. To avoid using a different command to re-enter insert mode (i vs. a), you can use the gi command, which re-enters insert mode at the position where it was last exited: inoremap <F4> <Esc>m'ggVG=``zzgi


3

Add these lines to your .vimrc: set tabstop=4 set shiftwidth=4 set expandtab After that, each new tab character entered will be changed to 4 spaces, old tabs don't. You must type: :retab This will convert all existing tabs in files to spaces. If you don't want to use retab, you can use perl to replace each tab by 4 spaces: perl -i.bak -pe 's/\t/ ...


3

Try this (you'll need to install multitail): multitail -du -t "$(head -n 1 filename)" filename or, for headers longer than one line: multitail -wh 2 -l "head -n 2 filename" filename If you want to follow command output instead of a file: multitail -wh 2 -l "command | head -n 2" -l command or use -t as appropriate. Note that you may need to use ...


3

^M is a Windows-specific EOL (End Of Line) and it consists of two characters: carriage return \r and new line \n. So you must include \n in your replace command as well: %s/\r\n//g If you want to stick with you original replace command, then you must first convert EOL-format of your file from Windows one to Unix one. You can use dos2unix tool to do that: ...


3

You can turn that default behavior off via :set noequalalways You then have to explicitly make windows equal size (e.g. with <C-w>=) Alternatively, you can just turn this off for the window height via :set eadirection=hor


3

You asked about how to hide the first letters, not to remove them, or scroll them out of sight - so here is how to actually hide it: Hide text in vim using conceal You can use matching, combined with syntax highlighting and the conceal feature to actually not show matched characters inside lines. To hide the first 25 chars of each line: :syn match ...


3

I think more in line with what you're looking for is horizontal scrolling. Z is the horizontal scrolling command key, followed by a direction to move with the left or right arrow key. First :set nowrap to disable line wrapping. Then press z,35,→ to scroll 35 spaces.


3

You can use vim's substitute command to accomplish this: :%s/\\cite{1,3-7,9}/\\cite{1,3,4,5,6,7,9}/g This will replace all occurrences of \cite{1,3-7,9} with \cite{1,3,4,5,6,7,9}. To replace only occurrences that exist on the current line you can use: :s/\\cite{1,3-7,9}/\\cite{1,3,4,5,6,7,9}/g Append c if you want vim to ask for confirmation ...


2

In command mode, try: :%s/^.\{35}// %s/pat/sub/: replace each occurence of pat with sub ^.\{35}: match first 35 characters of line This command remove first 35 characters of each line. You can read :h regular-expression for more details about regular expression in vim.


2

You can use the :edit command, without specifying a file name, to reload the current file. If you have made modifications to the file, you can use :edit! to force the reload of the current file (you will lose your modifications).


2

Depending on exactly what you want, this is either what mark.vim or general syntax highlighting do. Mark allows creating some number of distinct groups of highlighted patterns or extents. Specifying a particular regular expression is done with Leaderr by default. There's also a :Mark command. You can set the colourscheme using :MarkPalette.


2

Actually, as is often the case with vim, if you can think of the feature, someone has probably implemented it. In this case, you are probably looking for the Colorizer plugin. Note that though this plugin “works best” with gvim, it supports 88 and 256 color terminals. From the script site: The idea is to highlight color names and codes in the same ...


2

To expand any single instance of a range of the form m-n within a \cite{...} expression, you could perhaps do something like perl -pe 's/\\cite{(?:\d+,)*\K(\d+)-(\d+)(?=(?:,\d+)*})/sprintf "%s", join(",", ($1..$2))/e' file.tex


1

First, that nnoremap <C-C> <silent> <C-C> has the <silent> parameter in the wrong position; it works, but not the way you think it does (and it beeps). Better use this: nnoremap <C-C> <Nop> To avoid the insertion of ^C when aborting r, define a special mapping for that, too: nnoremap r<C-c> <Nop>


1

Those messages come from evince. They are emitted when evince detected a PDF file change and it reloads the file. You can workaround this via redirecting stderr of evince to /dev/null. That means you can search for the evince call in the vim-latex plugin source and replace something like evince <OPTS> <INPUT> with: evince <OPTS> ...


1

awk '/\r$/ {sub(/\r$/, ""); printf "%s", $0; next} {print}' file


1

You seem to have a filetype plugin that installs a buffer-local mapping for Ctrl-C. You can check with :verbose imap <buffer> <C-c> It's probably the default one, cp. :help ft_sql. The prefix key can be reconfigured via this (in your ~/.vimrc): let g:ftplugin_sql_omni_key = '<C-j>'


1

You can do something like this in your .vimrc: highlight Test ctermfg=red autocmd BufWinEnter * match Test /Power/ autocmd InsertEnter * match Test /Power/ autocmd InsertLeave * match Test /Power/ autocmd BufWinLeave * call clearmatches() Then when you open file, any text matches Power will be highlighted as red. This is a static way, you can write your ...


1

To match "something", but not after a specific "word", you can use \@<!; /\(word\)\@<! something/ For replacing "something" by "somethingelse", but only if "something" is not after "word": :%s/\(word\)\@<! something/ somethingelse/ From inside vim, show the description with :help /\@<!: \@<! Matches with zero width if the preceding ...


1

In bash with shopt -s extglob: for file in **/**; do [[ -f "$file" ]] && vim "$file"; done Note that, as per Stéphane's comment, prior to Bash 4.3 this would follow any symlinks in the directories covered.


1

In addition to manually refreshing the file with :edit, you can put into your ~/.vimrc :set autoread to make Vim automatically refresh any unchanged files. Also see :checktime.


1

vipe uses temporary files (for me in /tmp) to pass and receive the pipe contents to / from Vim. Because of the pipeline, previous vipe invocations cannot be re-edited anymore; they've already been re-read by vipe and sent along the pipeline. So, it should be sufficient to save the previous vipe temp file (as the original one is removed by vipe), and re-open ...


1

install vim 7.4 on Debian without removing half of the system Installing from source is a good choice. Compiling vim is not difficult at all. You can read more details and instructions here. make YouCompleteMe work Installing YouCompleteMe need some things more difficult but it's good documentation at YouCompleteMe github repo, try this and tell ...


1

Put the file to ~/.vim/syntax/xt.vim, and ensure that you have :syntax on in your ~/.vimrc. To edit a file with that syntax highlighting, use :edit +setf\ xt the-file or define a filetype detection rule, cp. :help new-filetype.


1

This looks like a general installation issue, nothing plugin-specific (for which you should open an issue against the plugin). Ensure that the plugin's bundle directory is contained in 'runtimepath', and that the plugin/vimchat.vim file is actually sourced: :set rtp? :scriptnames


1

To indent the all the lines below the current line =G So, to indent entire file, go to the beginning of the file (gg) and then indent all the lines below the current line (=G) gg=G To indent the current line == So, to indent n lines below the current line n== For example, to indent 4 lines below the current line 4== These are the simplest ...



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