Hatena::Groupvim

vim and plasticity

 | 

2009-06-17

Command-line mode

05:05

現ファイル名が%で表されることは知っていたけど、

:!javac %

それだけでは不便なので、もっと細かく指定出来ないものかと思っていた。

やっと発見。


6. Ex special characters				*cmdline-special*


In Ex commands, at places where a file name can be used, the following
characters have a special meaning.  These can also be used in the expression
function expand() |expand()|.
	%	Is replaced with the current file name.		  *:_%* *c_%*
	#	Is replaced with the alternate file name.	  *:_#* *c_#*
	#n	(where n is a number) is replaced with the file name of
		buffer n.  "#0" is the same as "#".
	##	Is replaced with all names in the argument list	  *:_##* *c_##*
		concatenated, separated by spaces.  Each space in a name
		is preceded with a backslash.
	#<n	(where n is a number > 0) is replaced with old	  *:_#<* *c_#<*
		file name n.  See |:oldfiles| or |v:oldfiles| to get the
		number.							*E809*
		{only when compiled with the +eval and +viminfo features}

ファイル名関連の取得修飾子。長いので抜粋。

							 *filename-modifiers*
	 *:_%:* *::8* *::p* *::.* *::~* *::h* *::t* *::r* *::e* *::s* *::gs*
The file name modifiers can be used after "%", "#", "#n", "<cfile>", "<sfile>",
"<afile>" or "<abuf>".  They are also used with the |fnamemodify()| function.
These are not available when Vim has been compiled without the |+modify_fname|
feature.
These modifiers can be given, in this order:
	:p	Make file name a full path.  Must be the first modifier.  Also
		changes "~/" (and "~user/" for Unix and VMS) to the path for
		the home directory.  If the name is a directory a path
		separator is added at the end.  For a file name that does not
		exist and does not have an absolute path the result is
		unpredictable.

	:h	Head of the file name (the last component and any separators
		removed).  Cannot be used with :e, :r or :t.
		Can be repeated to remove several components at the end.
		When the file name ends in a path separator, only the path
		separator is removed.  Thus ":p:h" on a directory name results
		on the directory name itself (without trailing slash).
		When the file name is an absolute path (starts with "/" for
		Unix; "x:\" for MS-DOS, WIN32, OS/2; "drive:" for Amiga), that
		part is not removed.  When there is no head (path is relative
		to current directory) the result is empty.
	:t	Tail of the file name (last component of the name).  Must
		precede any :r or :e.
	:r	Root of the file name (the last extension removed).  When
		there is only an extension (file name that starts with '.',
		e.g., ".vimrc"), it is not removed.  Can be repeated to remove
		several extensions (last one first).
	:e	Extension of the file name.  Only makes sense when used alone.
		When there is no extension the result is empty.
		When there is only an extension (file name that starts with
		'.'), the result is empty.  Can be repeated to include more
		extensions.  If there are not enough extensions (but at least
		one) as much as possible are included.

簡単なまとめ:

%:p が現bufferのfullPath。

%:h がHeader。file名抜かしたpath。

%:t がTail。Header以外。

%:t:r がRoot拡張子無しのfile名。

%:t:e がExtension。拡張子


拡張子を取り去るにはもっと簡単な方法が。

					*extension-removal* *:_%<*
If a "<" is appended to "%", "#", "#n" or "CTRL-V p" the extension of the file
name is removed (everything after and including the last '.' in the file
name).  This is included for backwards compatibility with version 3.0, the
":r" form is preferred.  Examples: >

よってjava fileをvim上でcompile,runするには

:!javac %; java %<

とすれば良いと。で適当にどこかのキーにMapすればいいと。


:au BufNewFile,BufRead *.java noremap <leader><leader> :!javac %; java %<<cr>

こんな感じか。


追記:

~/.vimrcに以下を追加して、

filetype plugin on

~/.vim/ftplugin/java.vimに以下を書いた。

nnoremap <buffer> <leader><leader> :<c-u>!javac %; java %<lt><cr>

もうfiletype-detectされてるため、autocmdはいらないようだ。c.vimとcpp.vimも作って試してみた。

参考:help filetypes


新しいfiletype作るなら

:help new-filetype

を参考にすると。

ヘルプ強い。

StitchesStitches2011/07/09 21:11These topics are so cofunsing but this helped me get the job done.

uvxenwtuvxenwt2011/07/10 00:245cnnWn <a href="http://veoutzanwfee.com/">veoutzanwfee</a>

jnxvmhvslkojnxvmhvslko2011/07/10 20:30CvbbSy , [url=http://mmhpnqhmsxvk.com/]mmhpnqhmsxvk[/url], [link=http://ahtezymyylxy.com/]ahtezymyylxy[/link], http://arivdxtdetii.com/

ipwdofcdfbipwdofcdfb2011/07/11 20:23SecTcO <a href="http://jcmlvsnfzpoe.com/">jcmlvsnfzpoe</a>

paljtydtaxrpaljtydtaxr2011/07/12 22:448CaEIS , [url=http://yiowgcntnemt.com/]yiowgcntnemt[/url], [link=http://aivyeqzrfzps.com/]aivyeqzrfzps[/link], http://awysqhficrfm.com/

pfizer viagrapfizer viagra2016/09/15 04:13
You've gotten good knowlwdge on this website. weferhervvbt

golistergolister2017/02/02 18:39
I could subscribe.

OiikbMubOiikbMub2017/05/23 11:09online payday loans mississippi
- <a href="https://onlinepaydayloanquickes.com">fast online payday loans
</a>
bad credit online payday loans
- <a href=https://onlinepaydayloanquickes.com/>online payday loans reviews
</a>

imnwgMubimnwgMub2017/05/23 19:07payday loans online
- <a href="http://paydayloansonlineglhf.com">payday loans online
</a>
paydayloansonlineglhf.com
- <a href=http://paydayloansonlineglhf.com/>paydayloansonlineglhf.com
</a>

izkmeMubizkmeMub2017/05/24 08:13anabolicsteroidsnpc.com
- <a href="https://anabolicsteroidsnpc.com">anabolic definition
</a>
what are steroids
- <a href=https://anabolicsteroidsnpc.com/>anabolicsteroidsnpc.com
</a>

iffygMubiffygMub2017/05/24 09:49anabolism
- <a href="https://anabolicsteroidsnpc.com">types of steroids
</a>
steroids online
- <a href=https://anabolicsteroidsnpc.com/>types of steroids
</a>

idserMubidserMub2017/05/24 11:28anabolic steroids side effects
- <a href="https://anabolicsteroidsnpc.com">anabolics
</a>
legal anabolic steroids
- <a href=https://anabolicsteroidsnpc.com/>anabolic pathways
</a>

StaceyDesStaceyDes2017/06/11 23:47loans for people with poor credit payday loans no brokers bad credit <a href=http://usa-payday-loans.org/>loans for people with bad credit rating</a> get a quick loan

StaceyDesStaceyDes2017/06/11 23:47cash loans for people with bad credit no direct deposit payday loans <a href=http://usa-payday-loans.org/>payday loans online pa</a> fast cash today

StaceyDesStaceyDes2017/06/11 23:52personal loans with fair credit i need a loan <a href=http://usa-payday-loans.org/>online easy loans</a> payday loans monthly payments

StaceyDesStaceyDes2017/06/12 02:38payday loans lake charles short term payday loan <a href=http://usa-payday-loans.org/>online personal loans</a> unsecured loan lenders

StaceyDesStaceyDes2017/06/12 02:38borrow cash now nimble small loans <a href=http://usa-payday-loans.org/>loan rates</a> payday loans nampa id

StaceyDesStaceyDes2017/06/12 02:42personal loans texas pay day laons <a href=http://usa-payday-loans.org/>easy loans for bad credit</a> payday loans louisville ky

StaceyDesStaceyDes2017/06/12 03:25need personal loan now money quick <a href=http://usa-payday-loans.org/>payday loans rockford il</a> need money right now

StaceyDesStaceyDes2017/06/12 03:25no fee loans loans in texas <a href=http://usa-payday-loans.org/>online personal loans for bad credit</a> loans bad credit

StaceyDesStaceyDes2017/06/12 03:28payday loans cheyenne wy ssi payday loans <a href=http://usa-payday-loans.org/>payday loans without a checking account</a> large unsecured loans bad credit

StaceyDesStaceyDes2017/06/12 18:43where can i get a small loan with bad credit payday loan nj <a href=http://usa-payday-loans.org/>payday loans salina ks</a> payday loans in arlington tx

StaceyDesStaceyDes2017/06/12 19:00payday loans benefits accepted small loan companies <a href=http://usa-payday-loans.org/>unsecured loans online</a> check advance loans

StaceyDesStaceyDes2017/06/12 19:15payday loan nj i need cash today <a href=http://usa-payday-loans.org/>cash advance tampa</a> loans bad credit

StaceyDesStaceyDes2017/06/12 19:15payday loans cleveland ohio payday loan online bad credit <a href=http://usa-payday-loans.org/>loans for bad credit no guarantor no fees</a> loans for disabled

StaceyDesStaceyDes2017/06/12 19:17loan for no credit easiest payday loans <a href=http://usa-payday-loans.org/>payday loans as seen on tv</a> utah payday loans

StaceyDesStaceyDes2017/06/12 21:48need cash now money lenders <a href=http://usa-payday-loans.org/>banks that do personal loans</a> immediate loans

StaceyDesStaceyDes2017/06/12 21:48american payday loan loan payday <a href=http://usa-payday-loans.org/>payday loan colorado springs</a> online cash advance

StaceyDesStaceyDes2017/06/12 21:48get cash loan now interest free loan <a href=http://usa-payday-loans.org/>no doc loan</a> first payday loan free

StaceyDesStaceyDes2017/06/13 01:12borrow money fast where can i borrow money <a href=http://usa-payday-loans.org/>real online loans for bad credit</a> check cashing payday loans

StaceyDesStaceyDes2017/06/13 01:12alternative loans cashusa <a href=http://usa-payday-loans.org/>signature loans for bad credit</a> online payday advance

StaceyDesStaceyDes2017/06/13 01:12cash loans columbus ohio unsecured personal loans poor credit <a href=http://usa-payday-loans.org/>payday lones</a> payday loans in pennsylvania

StaceyDesStaceyDes2017/06/13 03:28payday advances online how to get cash fast <a href=http://usa-payday-loans.org/>getting loan with bad credit</a> money loan with bad credit

StaceyDesStaceyDes2017/06/13 03:28check advance payday loans kansas city mo <a href=http://usa-payday-loans.org/>payday advance loan</a> payday loans norfolk va

StaceyDesStaceyDes2017/06/13 03:28bad credit need loan personal loan interest rates <a href=http://usa-payday-loans.org/>apply for loan with bad credit</a> short term online loans

StaceyDesStaceyDes2017/06/13 05:45credit check free next payday advance <a href=http://usa-payday-loans.org/>loans for bad credit</a> fast pay day loans

StaceyDesStaceyDes2017/06/13 05:45short term cash advance cash advance akron ohio <a href=http://usa-payday-loans.org/>non payday loans for bad credit</a> take a loan

StaceyDesStaceyDes2017/06/13 07:58pay day loans online online loan for bad credit <a href=http://usa-payday-loans.org/>basic bank account for bad credit</a> cash advance dayton ohio

StaceyDesStaceyDes2017/06/13 11:19www personal loan com cash advance miami <a href=http://usa-payday-loans.org/>long term loans for bad credit no guarantor</a> i need a loan today

StaceyDesStaceyDes2017/06/13 11:19delaware payday loans short cash loans <a href=http://usa-payday-loans.org/>bad credit loans online approval</a> direct loans for bad credit

StaceyDesStaceyDes2017/06/13 13:33loans for young adults ach loan <a href=http://usa-payday-loans.org/>online loan bad credit</a> same day payday loans direct lender

StaceyDesStaceyDes2017/06/13 13:33flexible loans money borrowing sites <a href=http://usa-payday-loans.org/>loan cash now</a> money lender

StaceyDesStaceyDes2017/06/13 13:33personal loans for bad credit in maryland lendingtree loans <a href=http://usa-payday-loans.org/>online lending</a> how can i get a loan

StaceyDesStaceyDes2017/06/13 15:44payday loans in montgomery al www payday loans <a href=http://usa-payday-loans.org/>defaulted loans</a> american payday loan

StaceyDesStaceyDes2017/06/13 15:44long term payday loan not a payday loan <a href=http://usa-payday-loans.org/>payday loan same day</a> compare payday lenders

StaceyDesStaceyDes2017/06/13 15:44payday cash advances money in minutes loan <a href=http://usa-payday-loans.org/>how to get fast cash</a> online payday loans texas

StaceyDesStaceyDes2017/06/13 18:00bad credit loans now lenders for people with bad credit <a href=http://usa-payday-loans.org/>short term bad credit loans</a> personal small loans

StaceyDesStaceyDes2017/06/13 18:00payday loan calgary emergency cash <a href=http://usa-payday-loans.org/>quick cash advance</a> loans from direct lenders

kgzflmAdenokgzflmAdeno2017/06/21 23:20what is a cash advance
<br />
<a href="http://paydayourloansonline.com#242/">best payday loans</a> <br />
<a href="http://paydayourloansonline.com#070/">personal loans </a> <br />
http://paydayourloansonline.com#440/ - payday loans online <br />
ace cash advance
#gagahshsnsnfbfhhw2333

kbviurAdenokbviurAdeno2017/06/23 09:06need a payday loans, castle payday loans reviews, payday loans no bank account needed, payday loans san antonio <a href="http://paydayourloansonline.com/#personal"> loans with bad credit </a> payday loans same day, payday loans birmingham al <a href="http://paydayourloansonline.com/#loan"> short term loans </a> easy payday loans online, payday loans peoria il, payday loans jackson ms, payday loans roanoke va, payday loans direct lenders only, can you have two payday loans at once http://paydayourloansonline.com/#loan - online payday loans faxless payday loans, payday online loans, payday loans in houston #helloganamana2233

BriaxVorBriaxVor2017/07/01 19:22Пожалуйста, прочтите инструкции ниже для правильного использования новой версии программы. От этого напрямую зависит, насколько эффективно Вы сможете применить преимущества именно последних версий программы. </br>
<a href=http://mail.ru>Bingosio</a>
Новый инструмент распознавания изображений: </br>
<a href=https://gooogle.com/>Bingosio</a>
В состав программного комплекса XRumer </br> включен новый инструмент распознавания изображений XEvil, значительно повышающий эффективность комплекса, и многократно расширяющий потенциальный охват ресурсов для размещения Вашей рекламы. По состоянию на </br> года программа способна распознавать свыше 8400 типов изображений – буквенных, числовых, арифметических. Подробности Вы можете прочесть на нашем сайте. </br>

DvuspvAdenoDvuspvAdeno2017/07/02 17:46hahgsgdnna - google.com google.com - hywyywkkkkkkzzzzsssss

DargtkAdenoDargtkAdeno2017/07/04 02:51hhhhhhbbbxbxcv - google.com google.com - hjgjasdfkjwieururu

jackHexjackHex2017/07/15 22:29We do not recommend specific pharmacies, but you can search for verified international online pharmacies at PharmacyChecker.
A pharmacy can refuse to fill our prescription if you are from another city say you live a mile from Orlando and you are trying to find your meds.
Generic ViagraGeneric Viagra is starting to replace it's original as customers become more educated to the...

<a href=http://kamagra100mgoraljelly.today>kamagra now</a>

jackHexjackHex2017/07/16 20:23It surpassed my expectations for learning and connection.
Aircraft departing the circuit from other legs must broadcast intentions and depart in a manner that does not conflict with aircraft in or joining the circuit.
How alprazolam affects pregnancy.

<a href=http://kamagra100mgoraljelly.today>kamagra100mgoraljelly.today</a>

DbkgefAdenoDbkgefAdeno2017/07/19 10:39google.com - #000999uuquuqyshshshx

nhldncAdenonhldncAdeno2017/07/29 02:47topzp68x1g</br>
free male enhancement</br>
<a href="http://malesenhancement.com"> king size male enhancement</a> </br>
<a href="http://malesenhancement.com"> male enhancement products</a> </br>
<a href="http://malesenhancement.com"> male enhancement pills that work</a> </br>
evoxa male enhancement

ctaletfmghctaletfmgh2017/08/05 10:13jpuyoxrn http://maydaviendn.com/component/k2/itemlist/user/19134 <a href="http://cartonerahued.net/index.php/component/k2/itemlist/user/423501">Where To Buy Rice Paper Uk</a> ここで、ラフィク

lendiccolendicco2017/09/11 11:03すべての
<a href=http://lendicoplus.com>lendicoplus</a>
投稿者

tshkilanttshkilant2017/09/13 08:25すべての
http://tshkila.com tvasset.com w7677.com whiterockers.com lendicoplus.com yahappimbls.com
投稿者

 |