Skip to main content
Share Your Experience: Take the 2024 Developer Survey
10 votes
Accepted

How to preview the result of markdown file edited in vim?

While I mostly agree with @romainl comment (markdown was made to be explicit enough not to need a preview) you can do this in different ways: [OSX / Unix] The instant-markdown plugin is a solution. ...
statox's user avatar
  • 50.1k
8 votes
Accepted

How do I use vim within a Unix pipe-line?

Move the special filename - before -e: cat test.md | vim -e -c'g/foo/p' -cq -s - ^ ✘ cat test.md | vim - -e -c'g/foo/p' ...
user938271's user avatar
  • 5,987
8 votes

Terminal borked after invoking Vim with xargs

The reason is that xargs sets stdin to /dev/null, whereas vim needs stdin to be /dev/tty. BSD xargs (e.g. Mac) solution: echo -e 'file1\nfile2' | xargs -o vim -o sets the stdin of xarg's child ...
wisbucky's user avatar
  • 950
6 votes

Vim custom key mapping not working in superuser mode

When you run vim using su or sudo, I believe it's running the root user's .vimrc (if there is one) instead of yours. I think the most "correct" way to resolve this is to use sudoedit rather than ...
Pak's user avatar
  • 1,114
5 votes

How can I automate filetype detection when using sudoedit?

tpope/vim-eunuch Like you've discussed, $SUDO_COMMAND can be used to find the original filename(s). Together with a nifty usage of fnameescape and doautocmd it is possible to deduce the correct ...
timss's user avatar
  • 291
3 votes

How do I edit crontab files with Vim (I get the error: 'temp file must be edited in place')?

@Martin's self-answer is correct. A variation though, for people like myself who try to limit populating their vimrc file with occasional exceptions -- here editing a crontab, is to use modelines. ...
JM. Marcastel's user avatar
3 votes
Accepted

Is there a platform independent way to use "${ENVVAR}more_text" in vim?

I tried to use backtick expansion, but that does not seem to be working on Windows. So I think the easiest solution is something like this: :exe ":e" $ABC."foobar.txt"
Christian Brabandt's user avatar
2 votes
Accepted

Cross-platform way to execute command with clean environment?

As any child process inherits the environment from its parent, you can temporarily redefine Vim's own environment before executing your tool: let [temp, $ENV_VAR] = [$ENV_VAR, ''] %!cmd let $ENV_VAR =...
Matt's user avatar
  • 20.8k
2 votes

How do I move cursor around on unix shell using VIM commands?

I'm not sure about csh specifically, but for sh, ksh, and Bash, set -o vi, and for Zsh I think bindkey -v. You can add that to your ~/.profile or whatever. You can also add this to your ~/inputrc: ...
Zac Anger's user avatar
  • 121
2 votes
Accepted

How to specify different tab widths for different languages?

The standard way to achieve that is to create for each type a file in: ~/.config/nvim/ftplugin: ~/.config/nvim/ftplugin/java.vim ~/.config/nvim/ftplugin/c.vim ~/.config/nvimftplugin/javascript.vim ~/....
Vivian De Smedt's user avatar
1 vote
Accepted

How to set fileformat based on file type?

There are in fact 4 different ways to do this. You can read all of them in :h new-filetype. I will only describe the simplest solution: In your user runtime directory, create a new file in your ...
r_31415's user avatar
  • 576
1 vote
Accepted

!v command UNIX - relation to Vi or vim

Traditionally, ! is used for history expansion. You can inspect the shell history by running the command history. So when typing !v your shell (I assume bash), will execute the last command that ...
Christian Brabandt's user avatar
1 vote
Accepted

Vim custom key mapping not working in superuser mode

timtowtdi As pointed out in the comments to the other answer you could also solve this with editing root's ~/.vimrc file. There are other options though. symlink If your personal ~/.vimrc doesn't ...
chicks's user avatar
  • 332
1 vote

What are the basics of vi editor?

<esc>:q! To close the file without saving. <esc>:wq To close the file with saving. Those are the first two commands that I teach people who need to use VIM in a pinch. They are useful, ...
dotancohen's user avatar
1 vote

How do I edit crontab files with Vim (I get the error: 'temp file must be edited in place')?

Not the same error but also happening quite often: Error detected while processing /root/.vimrc: line 2: E319: Sorry, the command is not available in this version: syntax enable line 7: ... ...
rubo77's user avatar
  • 111

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