Tag Info

Hot answers tagged

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 can count words and lines inside vi using vi's own counter: Press g and then CTRL-g. Then the bottom line look for example like this: Col 1 of 11; Line 1 of 106; Word 1 of 344; Byte 1 of 2644 Or use vi's method to call shell commands: :w !wc -w This calls the save (:w) command first and then wc -w and shows the output. Example: :w !wc -w 344 ...


4

Use external unix command nl. :'<,'>!nl -w 3 -n rz -s' '


4

The syntax for lookarounds in vim is different from the PCRE syntax that you appear to have assumed. Instead of (?! ) try \@! i.e. highlight SquishedCommas ctermbg=red guibg=red match SquishedCommas /, \@!/


3

In vim, you can use redir command. In command mode: :redir > vim.output | set fileencoding | redir END Then output of set fileencoding will be save to vim.output. There is many other options of redir, you can see :help redir for more details. This works in vim, not in vi.


3

To save a lot of clipboard text to file quickly, you can run cat > file.txt, paste the contents, then press Ctrl-d. If you have xsel installed, you can do :r !xsel to insert the "primary" (aka. "mouse") selection in Vim, or :r !xsel -b to insert the "clipboard" (Ctrl-c) buffer. You can also save the selection directly to a file with xsel >file.txt or ...


3

No you don't have to put the command from the page you linked to in your ~/.vimrc, you can just type them after issuing : in vim to get the command prompt. However if you put the lines: set foldmethod=indent set foldnestmax=10 set nofoldenable set foldlevel=2 as indicated in the link you gave, in your ~/.vimrc, you don't have to type them every time ...


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


2

mouse=a prevents the ability of copying and pasting out of vim with readable characters. Change mouse=a to mouse=r and that should fix your issue with that. one thing I am wondering is, are you changing the config file for your vim with the mouse set to mouse=a? orignal answer ^ If mouse=r doesn't give you all the copy past options change it to mouse=v ...


2

In MacVim, you need to unmap the Edit > Paste menu item in order to override the shortcut, then you can remap Cmd-V (D-v in MacVim parlance) to the appropriate command in each mode. I added this to my ~/.gvimrc and now everything works wonderfully: macmenu Edit.Paste key=<nop> noremap <D-v> "*P cnoremap <D-v> <C-r>* inoremap ...


2

The patch script is accessible here in it's own GitHub repo, titled: powerline-patcher. An experiment I first started by downloading the above patching script. $ git clone https://github.com/Lokaltog/powerline-fontpatcher.git I then selected a sample .ttf file to test out your question. $ ls -lr | grep ttf -rw-r--r--. 1 saml saml 242700 Jul 2 20:29 ...


2

A direct way to do it: vim ~/.bashrc && source $_ You can make an alias: alias vimbashrc='vim ~/.bashrc && source $_' This works in bash or zsh. In other shell, you must explicit name .bashrc to source to make it work: alias vimbashrc='vim ~/.bashrc && source ~/.bashrc'


2

A change is any command that modifies the text in the current buffer. You'll find all commands listed under :help change.txt. In insert mode, a change is further limited to a sequence of continually entered characters, i.e. if you use the cursor keys to navigate (which you shouldn't), only the last typed part is repeated. Commands like j are motions; i.e. ...


2

You don't have to use it systematically: I usually manually select folds by the motion or section. For example, folding a paragraph is zfip and folding the next 20 lines is zf20j. Use za to toggle and zd to remove. This requires a little more work but allows your folding to reflect the task at hand.


2

Sorry I am not able to comment yet. Try to run command :sudo -s by this you will login as root. Then, I guess, you can do whatever work you want to.


2

You can access environment variables in your vimrc using $NAME. ssh sets the environment variable SSH_CONNECTION within an SSH session to non-empty metadata about the connection. You can combine these two to run configuration code based on whether you're accessing vim over SSH or not: if $SSH_CONNECTION colorscheme solarized endif The body of the if ...


2

You need to tell vim using command! -bar that a command can be followed by another command with the pipe symbol |: command! -bar FixWhitespace %s/\s\+$//e command! FixCommas %s/,\S\@=/, /ge Now this is OK: command! Fix FixWhitespace|FixCommas but this isn't: command! Fix FixCommas|FixWhitespace See :h command-bar for more details. The error message ...


2

Some vim syntaxes set certain settings when the file is opened. As you've found, you can get around this by using an autocmd to set the setting after the syntax has finished. To get the autocmd to apply on all file types, use a *. For example: autocmd FileType * set noexpandtab


2

In command mode, run: :%!column -t But this does not align the first column. You should use Align plugin for more advance option. Or you could format it without vim, a perl way: perl -anle 'BEGIN{$"="\t"} $F[0] = sprintf("%3s", $F[0]);print "@{[@F]}"' file Set $" to whatever you want for delimiter.


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.


1

The appearance of the fold column (:help fold-foldcolumn) is fixed and cannot be changed; you'd have to modify Vim's sources and recompile. You can only use the :highlight FoldColumn ... command to adapt the visual appearance of it as a whole (e.g. by choosing different colors, lower contrast, to make this information less distracting).


1

The only different between them is cursor position. From :help motion.txt: f f{char} To [count]'th occurrence of {char} to the right. The cursor is placed on {char} inclusive. ...


1

Yes the main difference between them is the cursor position as you said. This comes in handy when you want to delete or change some characters for example. Suppose you have the following line: print "Hello, world!\n"; exit Suppose you want to change everything before the semicolon. To do that, you go to the beginning of the line (^) and then change ...


1

I did some more research for you and here is what I found - the key to autocompletion is the bash command complete. You can print the rules for vim using: complete -p vim Likewise you can remove these specific rules with: complete -r vim This command resets it to defaults - the usual paths and file names completion without any extra logic. That's ...


1

Perhaps could you reinstall bash-completion : apt-get install --reinstall bash-completion And have a look at file /etc/bash.bashrc : nano /etc/bash.bashrc And verify that the following line are well uncommented: if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ ...


1

Bash by defaults autocompletes only path and file names. However the mechanism is extensible and bash can be taught to perform different autocompletion for different programs. For example for git it can autocomplete the sub-command names (clone, commit) and revisions instead of just pathnames. Sometimes it's handy, sometimes quite annoying - for example when ...


1

You need to run vim as root. sudo vim /var/www/file


1

If you have xterm_clipboard feature, you can use the * and + registers. These registers interface with the X11 primary selection buffer, and clipboard (respectively). Thus if you've copied something via CTRL+c, you can paste it in vim with "+p. If you've simply highlighted it without copying, you can paste it with "*p. You can also make the * buffer the ...


1

Based on your description, it is very likely that the current working directory for vim or for your lualatex process is not the directory you were looking at, as: If you run lualatex directly it works as expected You don't get any error when running lualatex from vim That indicates that: lualatex works in general there must be a difference between when ...



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