Hot answers tagged

6

Actually, you don’t need saved sessions for this; vim -S will happily accept any file containing vimscript. So, write some commands for your custom layout (stolen from the other answer) edit file3 leftabove vsplit file2 split file1 And then do vim -S layout.vim. This also helps avoid cluttering the command and makes it easier to edit the layout commands.


6

You could try it like this: vim -c "lefta vsplit file2.txt|split file1.txt" file3.txt With the option -c you can specify commands that should be executed after the first file was loaded. So here: The file file3.txt is loaded. The command lefta vsplit file2.txt|split file1.txt is executed. This are in fact two commandsseparated by | lefta vsplit ...


4

Try to add the negative offset -1 to the second line specifier in the range passed to the first substitution command: v :g/^function /,/^}/- s/\n/@@@ :sort /^function / :%s/@@@/\r/g Otherwise, the newline at the end of your first function is replaced with @@@, which wrongly merges the first line of the second function with the last line ...


3

To answer your title question is pretty simple, just add this to your shell aliases (note untested, there may be syntax issues, but I think it gets the point across): vim() { while command vim $@; do done; } In other words, run vim in an infinite loop. If you quit with :q, The script will restart vim, and you can break out and really quit by using :...


3

Add this in your vimrc: nno <space>R :<c-u>call <sid>vim_quit_and_restart()<cr> fu! s:vim_quit_and_restart() abort if has('gui_running') | echo 'not available in GUI' | return | endif sil! update sil call system('kill -USR1 $(ps -p '.getpid().' -o ppid=)') qa! endfu And this in your bashrc: trap __catch_signal_usr1 ...


3

Personally, I’ve used endwise for a few years and been satisfied. It’s easy enough to add other languages if necessary, but it supports shell (among many others) out of the box. It will automatically insert « ending » statements when you hit enter, so if ... <CR> and the fi is added. Perhaps my favorite part is endwise is smart enough not to add ...


3

Here's what I would go for: autocmd FileType sh iab <buffer> then then<CR>fi<C-o>O<SPACE><BS><C-o>z That's for the then...fi, but you can apply it for the 2 other solutions as well Explanation autocmd allows you to specify a filetype (among other things), here sh I use abbreviations (iab) instead of mapping, as this ...


3

Shell originally used only backticks for command substitution: less `find . -type f` But these do not nest and suffer from other problems. Bash (and probably ksh, but I’m not up on the history there) used $() as a newer, improved command substitution. But that explains the difference and while the filetype matters—in fact, the shebang (#! line) matters! If ...


3

This is because the original Bourne shell only understands `...` - the standard $( ... ) syntax was added later. From syntax/sh.vim: " $() and $(()): {{{1 " $(..) is not supported by sh (Bourne shell). However, apparently " some systems (HP?) have as their /bin/sh a (link to) Korn shell " (ie. Posix compliant shell). /bin/ksh should ...


3

In Vim line continuation is done with a backslash on the new line. Like: noremap <C-F12> :!bash -c ' \git rev-parse --show-toplevel \\| xargs -I {} \ ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q {}' \<CR> Another point is the usage of | in the command line, as it is a command ...


1

Add a function like this to you ~/.bashrc: function vimwikipage() { vim -c "VimwikiIndex" -c "VimwikiGoto $1" } Now, you can open/create a specific Vimwiki page like this: $ vimwikipage ExampleVimwikiPage Explanation This command would be essentially equivalent to the following sequence of actions: $ vim \ww :VimwikiGoto ...


1

I agree any answer to this question will be somehow subjective, but I also agree with Eyal Karin that there may be an objective component too. I've been using the Neovim terminal as my main terminal for at least two years now, maybe more, even while SSH to a remote machine, and despite its rough edges, I cannot go back to a dedicated one, not because my ...


1

Adding let $TMP="/tmp" to init.vim, which should perhaps have been obvious, solved this with the exception of a couple of plugins which assume cmd.exe as the shell on Windows. I had previously tried setting it to various other directories, but I was always making the mistake of specifying them with the Windows path format.


1

I am on macOS with neovim. I will just provide my code: if exists('g:GuiLoaded') nmap <leader>rv :!osascript -e 'tell application "Terminal" to do script "sh /users/eyalkarni/vimpy3/vimqt.sh"'<CR> else nmap <leader>rv :!osascript -e 'tell application "Terminal" to do script "sh /users/eyalkarni/vimpy3/vimr.sh"'<CR> endif g:...


1

You can use -C flag vim -C somefile


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